My code is below
protected override void OnBarUpdate()
{
double x = EMA(5)[0];
}
Suppose CurrentBar be y, each time OnBarUpdate is triggerred, EMA(5) will be calculated from 1 (y bars before) to y (CurrentBar), won't it?
I guess it will not be recalculated each time. So is the above code same efficient as
the following code?
protected override void Initialize()
{
ema = EMA(5);
}
protected override void OnBarUpdate()
{
double x = ema[0];
}
are the following two codes same efficiency?
protected override void OnBarUpdate()
{
if (CurrentBar % 1000 == 0)
double x = EMA(5)[0];
}
protected override void Initialize()
{
ema = EMA(5);
}
protected override void OnBarUpdate()
{
if (CurrentBar % 1000 == 0)
double x = ema[0];
}
My third question is if one of the following two codes will calculate EMA(5) for five times in one bar.
protected override void OnBarUpdate()
{
for (int i=0; i<5;i++)
double x = EMA(5)[0];
}
protected override void Initialize()
{
ema = EMA(5);
}
protected override void OnBarUpdate()
{
for (int i=0; i<5;i++)
double x = ema[0];
}

Comment