I am trying to understand how the SMA indicator (supplied with NT6.5) works so I can write my own indicator (actually a port of DemandIndex from the AmiBroker AFL language).
Can you answer me what is Value ? I can't find it in the pdf userguide to NT v6 (so presumably it is not a system reserved word). Neither is it declared in the SMA indicator source code so it is not a local variable.
It is referenced in these two ways
1: double last = Value[1] * Math.Min ....
2: Value.Set(last + Input[0] ...... )
In 1: it would appear to be an array type (IDataSeries) but in 2: it appears to be a single variable (double)
Also, where does the SimpleMovingAverage code initially add all the prices?
I would have thought that the code would run along the following lines:
Initialise()
{
double last=0; // running sum of the prices
// now to add up all the prices for an initial total.
for (int count=0; count<Period; count++)
{
last=last + Input[count];
}
}
OnBarUpdate()
{
// And now on each bar update, add price of new bar and subtract
// price of last (Period) bar and divide by Period.
if (CurrentBar >= Period)
{
last = (last + Input[0] - Input[Period]) / Period;
}
// Plot a line
Plot0.Set(last);
}
// end
*** Cheers and thanx, MarkBN
BTW: I did search the forum to see if someone had perhaps already
ported this indicator, but sadly for me, it appears no.


Comment