For example,
Indicator method SMA:
Examples
double value = SMA(20)[0];
Print("The current SMA value is " + value.ToString());
In Ninja script for SMA however the code does not appear to use the SMA method but has the following code. Why doesn't it just use the SMA Indicator Method?
{
if (CurrentBar == 0)
Value.Set(Input[0]);
else
{
double last = Value[1] * Math.Min(CurrentBar, Period);
if (CurrentBar >= Period)
Value.Set((last + Input[0] - Input[Period]) / Math.Min(CurrentBar, Period));
else
Value.Set((last + Input[0]) / (Math.Min(CurrentBar, Period) + 1));
}
}
Comment