指標の計算がうまくいかない

最後のステートメントのインディケータの計算は、赤で強調表示されています。(例)OutPut3 [i] =(xx [i] yy [i])/ 2; // ??????????????????????

動作しません。私の目的は、1日と3日の移動平均(xx [i]とyy [i])を計算してプロットすることです。

これら2つの平均の平均

何がおかしいのですか?

ダブルオフセット= 0.0050。 // < – オフセットを希望の値に設定

double xx []; // ???????????????????????????????????????

double yy []; // ???????????????????????????????????????

#property indicator_chart_window

#property indicator_buffers 9 // limit = 8内部的には制限はありませんが、8しか表示できません。

#property indicator_color3黒

// —-バッファ

double OutPut3 [];

// —- INPUT(S)

extern intピリオド= 1。

// ———————————————– ——————-

// INIT |

// ———————————————– ——————-

int init()

{

// —-エラートラップ

if(Periods <= 0){Alert( "Invalid Periods");戻り値(-1)。 }

// —-表示スタイル

SetIndexShift(3,1);

SetIndexBuffer(3、OutPut3);

SetIndexStyle(3、DRAW_LINE、STYLE_DOT、1、Red);

SetIndexDrawBegin(3、期間);

// —-

(0)を返します。

}

// ———————————————– ——————-

// DEINIT |

// ———————————————– ——————-

int deinit(){return(0);} }

// ———- ————————————- ——————-

// START |

// ———————————————– ——————-

int start()

{

// —- MaxRecordsを検索

int count_bars = IndicatorCounted();

if(counted_bars <0)が(−1)を返す。

if(counted_bars> 0){counted_bars_; }

int MaxRecords = Bars-counting_bars;

期間= 1。

for(int i = 0; i <MaxRecords; i )

{

double sum1dayma = 0.0。

(int k = 0; k <ピリオド; k )

{

sum1dayma =(High [i k] Low [i k])/ 2。

}

// OutPut0 [i] = sum1dayma / Periods;

xx [i] = sum1dayma / Periods。 // ??????????????????????????

}

期間= 3。

(i = 0; i <MaxRecor ds; i )の場合

{

double sum3dayma = 0.0。

(k = 0; k <ピリオド; k )

{

sum3dayma =(High [i k] Low [i k])/ 2。

}

yy [i] = sum3dayma / Periods。 // ??????????????????????????

}

// —- xx [i]&yy [i]の平均を計算してプロットする

(i = 0; i <MaxRecords; i )の場合

{

OutPut3 [i] =(xx [i] yy [i])/ 2; // ??????????????????????

}

// —-

(0)を返します。

}


最初にxx、yyの配列サイズを設定する必要があります

それからそれらを使ってください!

ArrayResize(…..)関数を参照してください。

int ArrayResize( object&array []、int new _size)



1072: https://www.mql5.com/en/forum/104323


Originally posted 2019-08-02 22:11:45.

Translate »