View Full Version : Determining if an indicator value is null
newguy
10-16-2007, 12:32 AM
I created an indicator in which only some of the DataSeries items are assigned values. When I access an indicator value that happens to be null:
double d = MyIndicator().Plot0[0];
...the closing price of the current bar is assigned to variable d. Is that normal behavior? How can I determine if the current value of the indicator is null? I don't want to assign an arbitrary value because the value is plotted. I tried using the Reset() method but got the same results. Btw, the indicator plots fine on a chart.
NinjaTrader_Josh
10-16-2007, 12:50 AM
You should be able to assign null values to your DataSeries. Please check out this page http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?DataSeriesObject
Here is an excerpt from it pertaining to your case:
"Calling the Reset() method is unique and can be very powerful for custom indicator development. DataSeries objects can hold null values which simply means that you do not want to store a value for the current bar. Mathematically, you can correctly assign a value of zero however if the DataSeries was the primary DataSeries of an indicator whose values would be used for plotting (http://www.ninjatrader-support.com/vb/../HelpGuideV6/Plot.html), you may NOT want a zero value plotted. Meaning, you want a zero value for proper calculations but not a zero value for chart visualization. The Reset() method allows you to reset the current bar's DataSeries value to a zero for calculation purposes but NinjaScript would ignore this value when it plotted it on a chart."
NinjaTrader_Dierk
10-16-2007, 12:57 AM
We'll look into and let you know.
NinjaTrader_Dierk
10-16-2007, 08:30 AM
NT6.5 (first beta in 2 weeks) will have a "ContainsValue" method at the series to determine if there is a custom-set value in or no.
newguy
10-16-2007, 04:16 PM
Ok, I'll look forward to the NT 6.5 beta. Thanks both Dierk and Josh for your quick responses!