#property indicator_chart_window#property indicator_buffers 2#property indicator_plots 2//--- plot Label1#property indicator_label1 "Label1"#property indicator_type1 DRAW_LINE#property indicator_color1 clrRed#property indicator_style1 STYLE_SOLID#property indicator_width1 1//--- plot Label2#property indicator_label2 "Label2"#property indicator_type2 DRAW_LINE#property indicator_color2 clrWhite#property indicator_style2 STYLE_SOLID#property indicator_width2 1//--- indicator buffersdouble ExtLineBuffer[];
double ExtLineBuffer2[];
int InpMAPeriod=13; // Period//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit()
{
//--- indicator buffers mappingSetIndexBuffer(0,ExtLineBuffer,INDICATOR_DATA);
SetIndexBuffer(1,ExtLineBuffer2,INDICATOR_DATA);
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
//---return(0);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constint begin,
constdouble &price[])
{
//--- check for bars countif(rates_total<InpMAPeriod-1+begin)
return(0);// not enough bars for calculation//--- first calculation or number of bars was changedif(prev_calculated==0)
ArrayInitialize(ExtLineBuffer,0);
//--- sets first bar from what index will be draw
InpMAPeriod=20;
int i,limit;
//--- first calculation or number of bars was changedif(prev_calculated==0)// first calculation
{
limit=InpMAPeriod+begin;
//--- set empty value for first limit barsfor(i=0;i<limit-1;i++) ExtLineBuffer[i]=0.0;
//--- calculate first visible valuedouble firstValue=0;
for(i=begin;i<limit;i++)
firstValue+=price[i];
firstValue/=InpMAPeriod;
ExtLineBuffer[limit-1]=firstValue;
//ExtLineBuffer[i]=1;
}
else limit=prev_calculated-1;
//--- main loopfor(i=limit;i<rates_total && !IsStopped();i++)
ExtLineBuffer[i]=ExtLineBuffer[i-1]+(price[i]-price[i-InpMAPeriod])/InpMAPeriod;
ExtLineBuffer2[i]=ExtLineBuffer[i];
//--- return value of prev_calculated for next callComment(ExtLineBuffer[rates_total-1]);
return(rates_total);
}
//+------------------------------------------------------------------+
csvファイルを保存する際、データが列に分割されない。標準例のスクリプトでも、すべてのデータを1列で出力しています。
セパレータを指定する。
セパレータを指定する。
うまくいかなかった。Excelで開くと、ファイル形式が不明と表示され、列も分割されません。しかし、セパレータを指定せず、ファイルの拡張子も指定しないと、形式不明とも言われますが、テキストは列に分割されています...。
そんな風に、まだまだやりたいことがあるんです。
バッファライン、例えばclose[]ラインと左上にコメントが入るようなインジケータを作る ことは可能でしょうか?簡単な例を作ろうとしたため、端末がハングアップしてしまう
コメントをループから外す - もっと簡単にできるはずです。
インジケーターファイルの#resource オプションはいつから適用されるのですか?どなたかご存知ですか?プロジェクト全体を1つの.ex5ファイルにまとめたいと切に願います。
2つ目のバッファ(label2)がゼロである理由を教えてください。
1)OnCalculate関数は、クローズ、オープンなどが別々に存在する複数のバッファでは、なぜか問題がありません。
2) ぜひ使いたいのですが、上記のコードに記載されている移動平均の計算アルゴリズムが使えません
ExtLineBuffer2[i]が定数を含む異なる値を割り当てようとした - 常に0である