LOOP bars limited bars

To add comments, please log in or register
Marius Ovidiu Sunzuiana
921
Marius Ovidiu Sunzuiana  

   Dear coders,

    I want to loop back 20 bars. Is this correct ?

   for(int i=0; i<Bars;i++)

  {

  some code...[i] but I m interested how much loop is going to interate

}

  In this case it will loop on all Bars on chart. How can I loop only 20 bars back ? Thank you

Marius Ovidiu Sunzuiana
921
Marius Ovidiu Sunzuiana  
Shall I use some iBarShift or ?
nicholi shen
2321
nicholi shen  

This is what your loop should look like. 

   int bars = iBars(_Symbol, PERIOD_CURRENT);
   for (int i=0; i<bars && i<20; i++) {
      
   }
Marius Ovidiu Sunzuiana
921
Marius Ovidiu Sunzuiana  
nicholi shen:

This is what your loop should look like. 

 Thanks :) 

To add comments, please log in or register