Thursday, 5 September 2013

Calling a 3rd party indicator methods and properties in NinjaTrader

Calling a 3rd party indicator methods and properties in NinjaTrader

I am creating a TrendIndicator indicator in NinjaTrader with an external
indicator called SomeIndicator. I notice from the sample codes that I can
access the properties of the standard indicators, e.g. SMA(14)[0]. But
when I try to do that, I have this error
'NinjaTrader.Indicator.SomeIndicator' is a 'type' but is used like a
'variable'. So I try to use the instance object as in new(). The first
Print function is fine but the second Print doesn't work. The error in the
Output window is "Error on calling 'OnBarUpdate' method for indicator
'TrendIndicator' on bar 0: Object reference not set to an instance of an
object." Please advise. Thank you.
protected override void OnBarUpdate()
{
SomeIndicator ind = new SomeIndicator();
ind.SomeIndicator(14);
Print(ind.ToString());
double value = ind.Values[0];
Print(value.ToString());
}

No comments:

Post a Comment