private DataSeries ds;
void Initialize()
{
ds = new DataSeries(this); // Create DataSeries
}
void OnBarUpdate()
{
for(int i = 0; i <= 20; i++)
ds.Set(i,i); // fill the series again
double f = SMA(ds, 3)[0]; // SMA of last 3 bars
Print(f);
}
The problem is, that only at the first time f is correct (f = 1) i.e. (0 + 1 + 2) / 3
and on every new Print, f is not the SMA of those last 3 bars in ds, which are always 0, 1, 2....
also, I see that ds is growing itself with each new BarUpdate, why is that.
Thanks in advance.
Arnon.
Comment