Custom for loop

 

Is it possible to have a for loop that cycles in intervals as opposed to going through all numbers in a range?

For example if I had this loop

   double lows[]; 
   for(int i=1000;i>0;i--){
      lows[i]=Low[i];}

and I wanted to add Low prices for 0, 40,80,120,... up to 1000. How would I go about this?

 

sure, you can always use "i=i-20" (or "i-=20") instead of "i--" (which is actually i=i-1) like this:

 double lows[]; 
   for(int i=1000;i>0;i-=20){
      lows[i]=Low[i];}

thank you

Automated

--

real time grid trading video, +531 pips in 24 hours:

http://www.gridtradingcourse.com/videos/news_grid_trading_chfjpy_3/Grid_Trading_CHFJPY.html

http://grid9.forexmosaic.com/ - 8621 pips in 7 weeks of grid trading

 
ssn:

Is it possible to have a for loop that cycles in intervals as opposed to going through all numbers in a range?

For example if I had this loop

and I wanted to add Low prices for 0, 40,80,120,... up to 1000. How would I go about this?

Try this:

int i,j;
double lows[25]; 
for(j=0,i=0;i<=1000;i+=40,j++){
   lows[j] = Low[i]; //This will put the value you need from 0-24 in lows[] array in chronological order (0 being current Low[])
}
 
Automated wrote >>

sure, you can always use "i=i-20" (or "i-=20") instead of "i--" (which is actually i=i-1) like this:

thank you

Automated

--

real time grid trading video, +531 pips in 24 hours:

https://www.mql5.com/go?link=http://www.gridtradingcourse.com/videos/news_grid_trading_chfjpy_3/Grid_Trading_CHFJPY.html

https://www.mql5.com/go?link=http://grid9.forexmosaic.com// - 8621 pips in 7 weeks of grid trading



Thanks Automated
 
Archael wrote >>

Try this:




Thanks Archael,

will try this as well.

 

ssn wrote >>

  double lows[];
  for(int i=1000;i>0;i--){
      lows[i]=Low[i];}

The above won't work since the variable lows isn't defined as to size.

lows[1001] will work as will ArrayResize(lows,1001)

Reason: