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

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.

      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 chbruno, 04-24-2024, 04:10 PM
              4 responses
              50 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              10 responses
              398 views
              1 like
              Last Post beobast
              by beobast
               
              Started by lorem, Yesterday, 09:18 AM
              5 responses
              20 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by WHICKED, Today, 12:56 PM
              2 responses
              15 views
              0 likes
              Last Post WHICKED
              by WHICKED
               
              Started by Felix Reichert, Today, 02:12 PM
              0 responses
              4 views
              0 likes
              Last Post Felix Reichert  
              Working...
              X