How can I get the candle number on which the vertical line is drawn?
How can I get the candle number on which the vertical line is drawn? Sorry for my English.
- Moving Average Indicator
- Coding help
- trading hours and trading days
datetime when = (datetime)ObjectGetInteger(0, "MyVerticalLine", OBJPROP_TIME, 0); int shift = iBarShift(_Symbol, PERIOD_CURRENT, when); Print("Vertical line is drawn on candle ", shift);
Be careful if the object doesn't exist. If the object doesn't exist, when == 0 so iBarShift will be the oldest bar on the chart (depending on what you set for 'exact' in iBarShift)
Thanks.