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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        169 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        324 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        250 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        353 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        180 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X