Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy changes have no effect after recompilation & redeployment

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

    strategy changes have no effect after recompilation & redeployment

    I have this issue periodically and unsure how to resolve. Say I have a strategy that's running in production and I realize I need to make a change to it (e.g. a small logging output change). I make the change in the code, recompile, "disable" and "remove" the existing version, then I add a "new strategy" (from within the "Strategies" tab of the Control Center, of course), input the parameters and "Enable" the strategy. I do not see the code change take effect. It appears the old version of the strategy is 'sticking'. Why is that and how can I fix this? Thanks.

    #2
    Hello upshot,

    Compiling your NinjaScript files, will apply all of the changes that you have made to your script when you load a new instance of it.

    If you open up your code inside of the NinjaScript Editor Window do you see the changes that you made?

    If you see the changes, could you clarify what are you changing inside of the file?

    Please note that "Saving" or pressing the "Save" button in the NinjaScript file will not apply any changes to the code.

    Happy to be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Hi JC,

      In this case the code change was simply a logging change. I've had this issue frequently enough that now when I update a strategy I put some logging in the OnStartUp() method that spits some unique text to the output window so that I can verify my new changes took effect.

      Yes I see the changes if I open up the source in the editor. And I did an F5 (compile) before redeploying the strategy.

      I should throw out one other thing I've had issues with because maybe it's related. The way I structure my strategy code for all my strategies is they all descend from a common base class. This base class, of course, does certain tasks (e.g. basic logging output) that I want every strategy to do. Below is pseudo code for the basic idea of what I have going. Notice "VERSION 1" and "VERSION 2" of the trading strategy. The former omits the call to base.OnBarUpdate(). Note I store the source for the base and trading classes in separate files.

      The 'other issue' I mentioned I've noticed is this: say my computer is off. I fire it up and open up my code file for the trading class and make edits. I've noticed that in this situation, intellisense does not work. I can't see all the properties / methods inherited from Strategy class. To get intellisense to work I have to first open up the code file with the base class and compile it. Then when I go back to my trading class file and make edits I can see intellisense.

      So perhaps something like this is going on that's preventing my code changes from taking effect when I redeploy after code change?

      public class BaseStrategyClass : Strategy
      {

      protected override void OnBarUpdate()
      {
      //do common logging tasks here
      }

      }

      //VERSION 1
      public class MyActualStrategy : BaseStrategyClass
      {

      protected override void OnBarUpdate()
      {
      //do custom trading logic here, forgetting to call base.OnBarUpdate(). oops!
      }
      }

      //VERSION 2
      public class MyActualStrategy : BaseStrategyClass
      {

      protected override void OnBarUpdate()
      {
      base.OnBarUpdate();
      //do custom trading logic here
      }
      }

      Comment


        #4
        Hello upshot,

        Inheritance from one strategy to another is not something that we can support in NinjaTrader.

        That being said, if you want your strategies to share the same methods I would suggest using a defined method that uses a partial class for this. You may see our Help Guide at the following link for a "User Defined Method" that you can do inside of NinjaTrader to accomplish this.


        Let me know if the above method works for you.
        JCNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ct, 05-07-2023, 12:31 PM
        6 responses
        202 views
        0 likes
        Last Post wisconsinpat  
        Started by kaywai, Today, 06:26 AM
        0 responses
        1 view
        0 likes
        Last Post kaywai
        by kaywai
         
        Started by kevinenergy, 02-17-2023, 12:42 PM
        118 responses
        2,778 views
        1 like
        Last Post kevinenergy  
        Started by briansaul, Today, 05:31 AM
        0 responses
        9 views
        0 likes
        Last Post briansaul  
        Started by traderqz, Yesterday, 12:06 AM
        11 responses
        28 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X