iBarShift() returns indexes in reverse

To add comments, please log in or register
dmdamiyo
96
dmdamiyo  

Hi,

is there a way to make iBarShift to return indexes from left to right?


I like to work with Arrays where 0 means the oldest bar, butiBarShift return it the other way round.

Test case in OnCalculate:

  for(int bar_number=prev_calculated; bar_number<rates_total;
       bar_number++)
     {
      datetime bar_time = time[bar_number]; //first iteration - bar_number 0, time - the oldest bar (in my case sometime in 2017)
      int bar_number_h4=iBarShift(Symbol(),PERIOD_H4,bar_time,false);
      int bar_number_d1 = iBarShift(Symbol(),PERIOD_D1, bar_time, true);
      int bar_number_m15= iBarShift(Symbol(),PERIOD_M15,bar_time,false);
     }

In next iterations - bar number goes: 0,1,2,3,4,5

Time increases:

D'2017.04.28 14:00:00'

D'2017.04.28 15:00:00'

D'2017.04.28 16:00:00'

But bar_number_h4 i starting on a big number and getting lower: 3402, 3401, 3400...


Could you help?

Karel Nagel
680
Karel Nagel  
Maybe if you do Bars-iBarShift.
dmdamiyo
96
dmdamiyo  
Karel Nagel:
Maybe if you do Bars-iBarShift.
Good idea! Will try:)
William Roeder
19434
William Roeder  
nonSeriesIndex - Bars - 1 - seriesIndex; seriesIndex = Bars - 1 - nonSeriesIndex;
To add comments, please log in or register