View Full Version : Data Series question
ghoti
03-02-2010, 01:47 PM
I'm trying to understand Data Series Arrays (new to C# programming). I created the indicator using the Data Array tutorial, and it works fine. But, if I change the Open[0] to Open[1] I get nothing in the indicator panel and nothing in the output window (using a Print statement). Here is the line of code I change:
This one works fine:
myDataSeries.Set(Close[0] - Open[0]);
This one doesn't:
myDataSeries.Set(Close[0] - Open[1]);
Why doesn't the second one work?
Thanks
NinjaTrader_RyanM
03-02-2010, 02:05 PM
Hello Ghoti,
Likely you are running into the issue described in the post below:
http://www.ninjatrader-support2.com/vb/showthread.php?t=3170
In your case you need to add a check at the top of the OnBarUpdate() method:
if (CurrentBar < 1)
return;
ghoti
03-02-2010, 02:35 PM
Thanks Ryan,
I didn't mention, I did do some searching for the cause of this problem before I posted this question. I saw that post, it doesn't apply here. It is a daily chart with 365 days of history.
NinjaTrader_RyanM
03-02-2010, 02:48 PM
Hello Ghoti,
If you are attempting to access Open[1] but you do not have the CurrentBar check, then that post applies here. Amount of history will not matter as the problem happens when NinjaTrader attempts to access objects that don't exist. When you're looking at the first bar in the series (from the left), Open[1] does not exist.
Try adding that check and let us know your results.
ghoti
03-02-2010, 03:10 PM
I guess I need to read more carefully... That was it.
Thanks again.