Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Having issue with the DrawArrowDown()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Having issue with the DrawArrowDown()

    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.

    thanks
    geo



    #2
    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.

    Code:
    if(CurrentBar < 3)
        return;
    That should be placed at the very start of the OnBarUpdate() section.
    Last edited by NinjaTrader_JoshP; 08-12-2007, 08:30 PM.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      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

      Comment


        #4
        >> Any one know why tutorial 7 missing?
        Thanks fro the hint. We will redo the tutorials shortly. Sorry for any inconvenience.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        633 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        567 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X