Download MetaTrader 5

Switching timeframes recalculates whole indicator even with IndicatorCounted()

To add comments, please log in or register
RichPiano
175
RichPiano  

Hi guys,


So yeah, the question is in the title. I have an indicator which uses IndicatorCounted() to find out how many candles have not yet been calculated since "last time", but when i switch back and forth between two timeframes, IndicatorCounted() is always zero and thus the whole thing gets recalculated. You would assume that IndicatorCounted() serves a purpose in that very scenario at least, but i'm increasingly irritated by the uselessness of this function.


Am I missing something or is this indeed so? Anyway, how can i NOT recalculate the whole indicator after switching back to a timeframe where the indicator has already been calculated before? Cheers! :)

Keith Watford
Moderator
10645
Keith Watford  

Switching time-frames means that the whole indicator has to be recalculated.

You wouldn't want an indicator calculated on H1 showing on D1 would you?

RichPiano
175
RichPiano  
Keith Watford:

Switching time-frames means that the whole indicator has to be recalculated.

You wouldn't want an indicator calculated on H1 showing on D1 would you?


Obviously not, but i rather meant that if you switch from, let's say, M5 to H1 and then BACK to H5, then the indicator wouldn't have to be recalculated for M5 again except for the new bars that appeared in the mean time. But it still does recalculate which bugs me :/


Is there a way to get around this?

honest_knave
Moderator
2326
honest_knave  
RichPiano:


Obviously not, but i rather meant that if you switch from, let's say, M5 to H1 and then BACK to H5, then the indicator wouldn't have to be recalculated for M5 again except for the new bars that appeared in the mean time. But it still does recalculate which bugs me :/


Is there a way to get around this?


How would the indicator know you were just switching temporarily M5 --> H1 --> M5, versus switching to H1 and staying there?

Yes, you could code something that remembered where it was on each timeframe previously, but I would suggest it would be unnecessarily complicated. Most well-coded indicators really don't take too long to process all the bars.

To add comments, please log in or register