which candle number we are in

Back to topics list To post a new topic, please log in or register
FxTrader_ 2016.02.28 21:57


assuming that i'm viewing a one hour chart and i would like to know the current candle number from candle of four hours .( Is the current candle in one hour chart equal to (first candle , second candle , Third candle OR fourth candle))

I would like to show only the numbers as a comment.

   Comment("Bar number", 2)

D1 4H H1
6 Candle (H4) 4 Candle (H1) 2 Candle (M30)
24 Candle (H1) 8 Candle (M30) 4 Candle (M15)
48 Candle (M30) 16 Candle (M15) 12 Candle (M5)
96 Candle (M15) 48 Candle (M5)
288 Candle (M5)

GumRai 2016.02.29 01:01 #
  int Higher_Timeframe=PERIOD_H4;
  datetime higher_time=iTime(Symbol(),Higher_Timeframe,0);
  int shift=iBarShift(Symbol(),0,higher_time);
  Comment("Candle is number "+(string)(shift+1));

This should give you a start

Note that if there is not a candle that has the same open time as the higher time-frame. it may be out by 1

Back to topics list  

To add comments, please log in or register