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.
    JesseNinjaTrader Customer Service

    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 rjbtrade1, 11-30-2023, 04:38 PM
      2 responses
      75 views
      0 likes
      Last Post DavidHP
      by DavidHP
       
      Started by Stanfillirenfro, Today, 07:23 AM
      3 responses
      12 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by FitSpressoHonest, Today, 09:14 AM
      0 responses
      1 view
      0 likes
      Last Post FitSpressoHonest  
      Started by Davide999, 05-18-2023, 03:55 AM
      4 responses
      557 views
      1 like
      Last Post kcwasher  
      Started by rexsole, Today, 08:39 AM
      2 responses
      8 views
      0 likes
      Last Post NinjaTrader_Erick  
      Working...
      X