Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawHorizontalLine disallowed in Initialize??

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

    DrawHorizontalLine disallowed in Initialize??

    Hello,

    I had been writing some strategies and indicators earlier in the year. I had to stop because of .Net SP1 was not working with NinjaTrader. Thankfully (and as promised), the end of year version you've released resolves that.

    Now, back to my strategy problem. Unchanged strategy code now no longer runs a backtest. I get this error:

    ERROR: Failed to call method 'Initialize' for strategy 'bbStochCrossOver': 'DrawHorizontalLine' method can not be called from within 'Initialize' method.

    I had not received this error before in my strategy testing. Is this a bug, or am I doing something wrong? Should I move my DrawHorizontalLines to OnBarUpdate, and only draw on the 1st bar. An example of this DrawHorizontalLines would be Pivot lines. They are only drawn once, and at the beginning, so Initalize makes good sense to me?

    What are your thoughts?
    Thanks,

    Brian

    #2
    Hello,


    You will need to move the DrawHorizontalLine() to the OnBarUpdate() block.
    DenNinjaTrader Customer Service

    Comment


      #3
      Ok. I will.

      Was this a change in the latest version?

      Comment


        #4
        No. This was always the case. You should not use Initialize() for any indicator logic.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        582 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        338 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X