Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Failed to Restore Strategy Error

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

    Failed to Restore Strategy Error

    I want to create a strategy that exposes a list of custom objects as a parameter. The reference sample at the link below contains an indicator that does exactly that (Use case #5). I have copy and pasted the code in to a strategy, but if I have the strategy applied to a chart and compile the code, I get the error message below.

    Reference Sample:


    Error Message:
    Code:
    2019-07-27 10:22:33:527|3|4|Error on getting/setting property 'MyListValues' for NinjaScript 'Test1': Object of type 'System.Collections.ObjectModel.Collection`1[NinjaTrader.NinjaScript.Strategies.PercentWrapper]' cannot be converted to type 'System.Collections.ObjectModel.Collection`1[NinjaTrader.NinjaScript.Strategies.PercentWrapper]'.
    2019-07-27 10:22:33:658|3|4|Unable to create instance of NinjaScript 'Test1'. Most likely either the implementation no longer exists, there is no default constructor defined, the default constructor does not work correctly, or the 'OnStateChange' implementation for State=SetDefaults is flawed: System.InvalidOperationException: 'BarsRequiredToTrade' cannot be set from this state. Please see the Help Guide article on 'BarsRequiredToTrade' for more information.
       at NinjaTrader.NinjaScript.StrategyBase.set_BarsRequiredToTrade(Int32 value)
       at NinjaTrader.NinjaScript.StrategyBase.CopyTo(NinjaScript ninjaScript)
       at NinjaTrader.Gui.NinjaScript.StrategyRenderBase.CopyTo(NinjaScript ninjaScript)
       at NinjaTrader.NinjaScript.Strategies.Test1.CopyTo(NinjaScript ninjaScript) in c:\Users\Tyler\Documents\NinjaTrader 8\bin\Custom\Strategies\Test1.cs:line 133
       at NinjaTrader.NinjaScript.NinjaScript.Clone()
    2019-07-27 10:22:33:658|3|16|Failed to restore Strategy 'NinjaTrader.NinjaScript.Strategies.Test1'. Most likely (a) the implementation changed or (b) one or more properties have been renamed or removed or (c) the custom assembly which implements this Strategy no longer is there.
    Is there a different method to accomplish the same thing in a strategy?
    Attached Files

    #2
    Hello SystemTrading,

    This sample has been added to the help guide linked below.


    I've tested the script but I am not able to reproduce this error.


    Have you made changes to the script or compiled?
    After compiling have you removed the instance (existing row on the Strategies tab) of the strategy and added a new instance?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,
      Thank you for looking in to this. This test code was taken from that sample. I copy and pasted the code from the sample to the Test strategy. I did not modify it at all.

      In your test, you did not reload the strategy after compiling. Please see the brief video below.
      World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.

      Comment


        #4
        Hello SystemTrading,

        If you have compiled, then you need to remove the instance of the script and add a new instance.

        May I confirm you are getting this error after adding a new instance of the script?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          No, the error does not occur if I add a new instance. However, the sample indicator that you provided does not have the same issue. It can get frustrating as I usually compile code dozens of times each day.

          Comment


            #6
            Hello SystemTrading,

            I did some digging and found this has been reported and is a limitation with strategies for now.
            The strategy instance (added strategy row) must be removed and re-added.

            This is being tracked with ID# NTEIGHT-13751.
            I've added this thread to the ticket to track demand.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks Chelsea!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              56 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              132 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              73 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              49 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X