Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.HorizontalLine fails on 5, 6, 7 DaysBack

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

    Draw.HorizontalLine fails on 5, 6, 7 DaysBack

    Attached is a simple indicator to demonstrate a problem with Draw.HorizontalLine that causes it to fail only with particular DaysBack settings.

    To reproduce:
    1. Open a NinjaScript Output window.
    2. Connect to a data feed
    3. Create a 30 minute chart of ES 12-16 starting with DaysBack = 1.
    4. Add the gws\TroubleDrawHLine indicator, which should draw a horizontal red line at 2126.00.
    5. Open the Data Series and change DaysBack to 2 and hit Apply.
    6. Repeat for DaysBack 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ...

    The error occurs with DaysBack set to 5, 6, 7 and 12, 13, 14. Probably others as well, but I didn't check further.
    Attached Files

    #2
    Hello,

    I believe this would be because you are trying to draw from OnStateChange. This is noted that it will not work here as note #3: http://ninjatrader.com/support/helpG...hlightsub=Draw

    You would instead need to use OnBarUpdate and surround the code with a check for the state:

    Code:
    if(State == State.Historical)
    {
    	Draw.HorizontalLine(...);
    }
    I look forward to being of further assistance.

    Comment


      #3
      Interesting that it works most of the time when called from OnStateChange, just seemingly not when DaysBack crosses a weekend.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      650 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      370 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      577 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X