#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文件时,数据不会被分成几列。即使是标准例子中的脚本,也会在一列中输出所有的数据。
指定分离器。
指定分离器。
没有成功。在Excel中打开时,它说是未知的文件格式,而且也不分栏。但如果你不指定分隔符,也不指定文件扩展名,它也会说格式不明,但文本被分成了几列......
像这样的事情还有很多。
是否有可能创建一个指标,使其有一个缓冲线,例如close[]线,并在左上方有一个注释?我试图做一个简单的例子,所以我的终端挂了
把评论从循环中拿出来--应该会更容易。
何时将#资源 选项应用于指标文件?有谁知道吗?我非常希望能把整个项目合并成一个.ex5文件。
请解释为什么第二个缓冲区(label2)是0
1)由于某些原因,OnCalculate函数 在处理多个缓冲区时没有问题,其中有单独的关闭、打开等。
2) 我很想使用它,但它未能使用上述代码中描述的移动平均线计算算法。
ExtLineBuffer2[i]试图分配不同的值,包括常数 - 总是零