Noob - Use indicator in 1 tick, but is processed in all ticks?

 

Hi there,

 

Just a question to make me understand for a bit how Metatrader works. I am confused about how the indicators are used. So any clarification I can get is more then welcome :)

 

Question: I notice that for example, if I call the MA indicator just once in my entire EA, it will still show up completely calculate in the chart window.. Its not just 1 point that it has calculated, but the entire line is drawn, meaning it processed on every tick.

 

Is this default behaviour? It doesn't matter if you call an indicator just once, it will always be permanently 'attached' and processed on every tick?


Hope it makes any sense,

 

Thanks! 

 

I have never seen the MA in the chart window if it is only called by the EA. It has to be attached as an indicator for the MA line to show. In the tester it is added at the end of the test.

I'm not sure as I can't think of any time that I would call an indicator just once in an EA, but I believe that if it is not accessed for a certain length of time, then it is unloaded.

 
Brandsma: if I call the MA indicator just once in my entire EA, it will still show up completely calculate in the chart window..  Its not just 1 point that it has calculated, but the entire line is drawn, meaning it processed on every tick.
  1. False. You get the double from iMA(). You won't see anything on the chart unless you add a moving average to the chart and that is a separate indicator.
  2. Yes, it calculates all bars and updates bar zero per tick. All you're doing is reading out of its buffer. Nothing else needs to be calculated wether you read one value or multiple.
  3. Would you really want it to calculate the value every time you ask it? Remember a EMA requires all earlier bars to be calculated to get the requested bar's value. The SMA doesn't need to sum n bars, it can update sma(0) = sma(1) +(v[0] - v[n+1]) / n.