Indicator calculation

 
Can anyone tell me if indicator arrays (including custome indicators) are calculated every time they are called, or whether it is a once per chart, then whenever a new tick or bar is completed?

For instance, if I call iCustom() twice in the same tick, will it be much slower than if i call it once, store it, and then use the stored value.

ie

{
if (iCustom(blah, blah, blah) > 10) do this;
if (iCustom(blah, blah, blah) < 10) do that;
}

compared to

{
a = iCustom(blah, blah, blah);
if (a > 10) do this;
if (a < 10) do that;
}

if it calculates once per tick.bar then the first example will be faster, but otherwise the second example will be.

I have written an indicator that is very slow to calculate, so I am trying to improve performance all round!

Cheers,
Charlie
 
Once per calling series (in common case - once per tick)

in your first sample your custom indicator will be calculated once and called twice
in your second sample custom indicator will be calculated once too but called once.

One function calling is faster than 2 function callings.
 
Thanks Stringo.

Every tick explains why it is so slow.

The indicator is capable of calculating only the latest bar. Is there a way of making the rest of the series persistent between ticks, so that only the latest bar needs to be recalculated?
 
sec help for function:

IndicatorCounted()
Reason: