好奇怪的输出结果,哪个能解释

 
#property  indicator_separate_window
#property  indicator_buffers 1
#property  indicator_color1  Silver
#property  indicator_width1  2
double     MacdBuffer[];
int init()
  {
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,MacdBuffer);
   return(0);
  }
int start()
  {
   double test[10];
   int counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   for(int i=0; i<limit; i++)
      MacdBuffer[i]=i;
   return(0);

  }

放在M1分钟图表运行10分钟,奇怪输出结果是: MacdBuffer[3],MacdBuffer[4],MacdBuffer[5]居然全部是等于2 ,为什么会这样?

 

测试下来并没有遇到你说的情况。一般情况下,已经计算过的指标柱数比总柱数少1~2

 

 

因为大部分情况下 ,随时间流逝, imit <=3,

于是、总把limit-1 赋值给数组的上一个、上上一个元素