Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Sparkyboy, Today, 10:57 AM
        0 responses
        3 views
        0 likes
        Last Post Sparkyboy  
        Started by TheMarlin801, 10-13-2020, 01:40 AM
        21 responses
        3,917 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by timmbbo, 07-05-2023, 10:21 PM
        3 responses
        152 views
        0 likes
        Last Post grayfrog  
        Started by Lumbeezl, 01-11-2022, 06:50 PM
        30 responses
        811 views
        1 like
        Last Post grayfrog  
        Started by xiinteractive, 04-09-2024, 08:08 AM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X