Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Saving strategy "state"

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

    Saving strategy "state"

    Hi there,

    Apologies in advance for not having actually *tried* this yet... but I just wanted to ask the question before I got myself in too much trouble.

    I'm planning to go live autotrading my (interday) strategy later this week. For redundancy purposes, I want to make sure I can export/save my strategy's parameters (as well as any other "state" about the current run... existing stop orders?), and restore the same strategy on a different computer.

    How would I go about that?

    #2
    If you are referring to a NinjaScript strategy, this is not possible between machines or on the same machine. Once a strategy is terminated, it will restart fresh, as if it never ran before.
    RayNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Ray View Post
      If you are referring to a NinjaScript strategy, this is not possible between machines or on the same machine. Once a strategy is terminated, it will restart fresh, as if it never ran before.
      I'm not sure exactly how to interpret this.

      Other platforms I've worked with (like Wealth Lab) are designed to run this way on every bar. Every new bar of data is essentially executed on a strategy as if there was no previous state; it builds up hypothetical positions based on the "start" date, and then goes from there. Is that also how NinjaScript strategies function?

      Or are you saying that an intra-day strategy, once initiated, shouldn't be allowed to stop? And if it stops (overnight, while there are no bars)... the results will be different than if it hadn't been stopped?

      Comment


        #4
        Maybe we are on not on the same page.

        - You can export your strategy code and import it from one PC to another via File > Utilities

        If you want to start a real-time strategy that is executing orders in a real-time brokerage account, then mid stream, stop this strategy on PC A, then go to PC B, start the strategy --> Then you can do this but on PC B, it will re-calculate the strategy state from a historical sense which may or may not match what the strategy was doing on PC A.
        RayNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Ray View Post
          Maybe we are on not on the same page.

          - You can export your strategy code and import it from one PC to another via File > Utilities
          I've been copying the .cs file from the Strategies folder back and forth (actually using Subversion CVS). Any downside to doing that?

          If you want to start a real-time strategy that is executing orders in a real-time brokerage account, then mid stream, stop this strategy on PC A, then go to PC B, start the strategy --> Then you can do this but on PC B, it will re-calculate the strategy state from a historical sense which may or may not match what the strategy was doing on PC A.
          I would like to better understand this... what are the possible reasons that would cause it *not* to match what the strategy was doing on PC A?

          I'm not doing anything tick based; I'm at worst on 5 minute bars, at best on 30 minute bars. I'm also using a single provider for all data (historical and live).

          Comment


            #6
            1) I don't think there would be a downside
            2) There are many reasons, here are a few -

            - The real-time bars built while the strategy was running does not match historical bars
            - The orders execute in real-time are just different than what occurs in backtest, when you restart your strategy on PC B, even assuming the real-time and historical data is identical, orders re-calculated on historical data will fill differently than what actually happened in real-time and thus there is a mismatch
            RayNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Ray View Post
              1) I don't think there would be a downside
              2) There are many reasons, here are a few -

              - The real-time bars built while the strategy was running does not match historical bars
              - The orders execute in real-time are just different than what occurs in backtest, when you restart your strategy on PC B, even assuming the real-time and historical data is identical, orders re-calculated on historical data will fill differently than what actually happened in real-time and thus there is a mismatch
              Ray,

              Understand the issue with bars being different.

              On the order execution side... on PC A, you're saying NinjaTrader tracks positions (fill, avgPrice, etc) as they're executed through the broker. But if it's terminated, this information is subsequently lost? If so, that's definitely a form of "state" that I was referring to, and it'd be very useful if that information could be saved/exported/restored.

              But for practical purposes, I think I'll be okay in any case, since my code shouldn't be so highly dependent on the details of how orders execute... I'm okay with being off a percentage point or two.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by wzgy0920, 04-20-2024, 06:09 PM
              2 responses
              27 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 02-22-2024, 01:11 AM
              5 responses
              32 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 04-23-2024, 09:53 PM
              2 responses
              49 views
              0 likes
              Last Post wzgy0920  
              Started by Kensonprib, 04-28-2021, 10:11 AM
              5 responses
              193 views
              0 likes
              Last Post Hasadafa  
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,235 views
              0 likes
              Last Post xiinteractive  
              Working...
              X