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

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 judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        53 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Today, 06:52 PM
        4 responses
        33 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        5 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        19 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        6 views
        0 likes
        Last Post cre8able  
        Working...
        X