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

Error with Draw.Ray Help Please

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

    Error with Draw.Ray Help Please

    Whenever I use this Draw.Ray(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, bool isGlobal, string templateName)

    I get the following error:

    Unhanded Exception: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

    Please let me know what could be causing it.

    I have even tried a different function:
    Draw.Ray(this,"test",0,136,1,137,Brushes.Red);
    Something that simple causes my error as well.
    This all happened since the most recent version of NT8

    #2
    Hello trader3419,

    Without the full code I’m unable to test on my end. Furthermore, debugging customer code is out of the scope of NinjaScript support. However, if you’d like I could have someone from our business development team pass over a list of third party developers that you could contact about debugging your code. If that is the case, please send me an email to platformsupport[at]ninjatrader[dot]com with the text "ATTN Jim" and this thread's URL.

    I’ve provided some links which you may find helpful on debugging.

    Debugging: http://ninjatrader.com/support/forum...ead.php?t=3418

    TraceOrders: http://ninjatrader.com/support/forum...ead.php?t=3627

    Indexing issues: http://ninjatrader.com/support/forum...ead.php?t=3170
    JimNinjaTrader Customer Service

    Comment


      #3
      Can you at least tell me what would cause Draw.Ray to throw that type of error?

      Comment


        #4
        Hello trader3419,

        The Indexing issues link covers some issues seen like the error you are reporting.

        It could be, for example, that on the first bar formation, OnBarUpdate() will call Draw.Ray(this,"test",0,136,1,137,Brushes.Red); As it is referencing the an ending point as the previous bar, it will not have any knowledge of this bar because a "previous" bar has not been created yet.

        An issue like this could be corrected with a return condition that checks for enough bars:

        Code:
        if (CurrentBars < 1)
        	return;
        JimNinjaTrader Customer Service

        Comment


          #5
          My code draws the ray after a mouse click. There are enough bars.
          Any other ideas?

          Comment


            #6
            Without the full code and only knowing the issue you are experiencing is an indexing error, I cannot provide much more input.

            You could try placing a Print() statement that prints the price data for the barsAgo that you are referencing in the Draw.Ray() call.

            You may additionally wish to use IsValidDataPoint() to verify that the data points are valid before referencing.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by junkone, Today, 11:37 AM
            0 responses
            2 views
            0 likes
            Last Post junkone
            by junkone
             
            Started by quantismo, 04-17-2024, 05:13 PM
            5 responses
            34 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by proptrade13, Today, 11:06 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by love2code2trade, 04-17-2024, 01:45 PM
            4 responses
            34 views
            0 likes
            Last Post love2code2trade  
            Started by cls71, Today, 04:45 AM
            2 responses
            10 views
            0 likes
            Last Post eDanny
            by eDanny
             
            Working...
            X