ChangChun+China
Experience: Intermediate
Platform: Ninja Trader 8
Trading: Futures
Posts: 4 since Oct 2011
Thanks Given: 1
Thanks Received: 0
|
Hi all,
Sorry for the simplicity of my question. I am learning to code, and stuck with the first example I am reading: SMA.
protected override void OnBarUpdate()
{
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));
}
}
It seems that Value[1] here should represent the median one bar ago, is this correct?
I tested the the "Value[0]" on a chart, but it shows that it is equal to Close[0].
Quite confused with how NinjaScript would process price data .
|