PDA

View Full Version : Having issue with the DrawArrowDown()


geoarb
08-12-2007, 08:19 PM
Hi ,

I copied and pasted the code from the example exactly and it compiles fine. Once I add the indicator nothing happens but I get an interesting error in the log.

Error on calling the 'OnBarUpdate' method for indicator '3BarBearishReversal' on bar 0: Index was out of range. Must be non-negative and less than the size of the collection'

After a few hours thinking the logic was wrong somehow, i just put a negative sign in front of all the index like:

if (High[-2] > High[-3] && High[-1] > High[-2] && Close[0] < Open[0])
DrawArrowDown(CurrentBar.ToString(), 0, High[0] + TickSize, Color.Blue);

I still get the error but now the arrows have started showing up but they are displaced a few bars.

Also the Level 7 ninjascript tutorial missing in the help is not helping?

Where am I going wrong? I just copied and pasted the example.:confused:

thanks
geo

NinjaTrader_Josh
08-12-2007, 08:27 PM
No, you don't need the negative signs. 0 means latest bar. 1 means previous bar. 2 means previous bar of previous bar. etc etc.

The reason you are getting the error is because on the first bar there are no previous bars so you can't access High[2] or High[3]. You need to add this to your code.

if(CurrentBar < 3)
return;That should be placed at the very start of the OnBarUpdate() section.

geoarb
08-12-2007, 08:34 PM
works like a charm. Ahhh should have read Tutorial 3 much more carefully.

Much obliged.


Any one know why tutorial 7 missing?


Looks like this board is soon going to be really rich with information !!

thanks
Geo

NinjaTrader_Dierk
08-12-2007, 11:33 PM
>> Any one know why tutorial 7 missing?
Thanks fro the hint. We will redo the tutorials shortly. Sorry for any inconvenience.