variable shift parameter

 

hi everyone,

So i am working on this code. I am looking to get the prices over a period of 24*60 minutes on a minute by minute basis. Now the iclose function takes symbol, time frame and shift as inputs. i was wondering if there is any way to make this shift a variable. something like run shift[0] to shift[24*60] in a loop 24*60 time. is it possible to incorporate this into the iclose function?

 

Put a variable instead of the zero in shift[0]

 

cryptex, you want something like this. You simply change the "shift" parameter in the iClose() function to change the price you are looking up.

Using minutes, to get the close of the current bar, you would do iClose(Symbol(),PERIOD_M1,0), to get the close of one bar ago, you would do

iClose(Symbol(),PERIOD_M1,1), notice the "1" instead of a "0". This code will loop through the closes(minute-by-minute) of the past 24*60 bars.


int toCount = 24 * 60;
   for( int i = 0; i < toCount; i++ ){
      double close = iClose(Symbol(),PERIOD_M1,i);
      //Do what you want with price here.
   }
 
ya thanks for the help. i tried the same exactly the same. just "j" instead of "i". had errors. never the less thanks for the help. i'll check my code again. must have made some mistake. :D thanks again.
 
ah got it. forgot to write double before close :D my bad