run 10 mintues on M1 chart, the result is wrong, why?

 
#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);

  }

MT4, the indication run 10 mintues on M1 chart,then  the result is wrong,  MacdBuffer[3],MacdBuffer[4],MacdBuffer[5] all equal 2 ,why? 


Documentation on MQL5: Language Basics / Preprocessor / Program Properties (#property)
Documentation on MQL5: Language Basics / Preprocessor / Program Properties (#property)
  • www.mql5.com
Language Basics / Preprocessor / Program Properties (#property) - Reference on algorithmic/automated trading language for MetaTrader 5
 

Forum on trading, automated trading systems and testing trading strategies


Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


 
1648401654c:

MT4, the indication run 10 mintues on M1 chart,then  the result is wrong,  MacdBuffer[3],MacdBuffer[4],MacdBuffer[5] all equal 2 ,why? 


It's what is coded. First run : limit= Bars, further run : limit = 0 or 1.
 
angevoyageur:
It's what is coded. First run : limit= Bars, further run : limit = 0 or 1.

why run after 10mintues ,  MacdBuffer[3]=2,MacdBuffer[4]=2,MacdBuffer[5]= 2 ?

I think after 10mintues ,they should be   MacdBuffer[3]=1 , MacdBuffer[4]=1,MacdBuffer[5]= 1 

Reason: