Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Re-syncing R based strategies

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

    Re-syncing R based strategies

    My understanding is that NT has a simplistic way of re-syncing ongoing strategies, which does not bode well if you auto-trade R based unit sizes. For instance - let's say I take 1R of EURUSD which comes out to 155,000 units (1.55 lots). A few days later NT crashes and I am relaunching it. However since then my R size has increased (because I banked profit in between) and thus on syncing NT attempts to take 160,000 units. That means that it won't sync properly - at least this is how I understand the problem. I am attempting to fix it by persisting the open campaign's unit size to file.

    It doesn't affect small accounts on the futures side but on the forex side on IB. However above $500k we run into the same problem in the futures.

    Example Gold:

    Account size: $500k
    Point value: $100
    Stop loss in ticks: 20
    Contracts at 1%: 25

    A week later we've banked $20k:

    Account size: $520k
    Point value: $100
    Stop loss in ticks: 20
    Contracts at 1%: 26

    So per my understanding - on a crash or relaunch NT will not sync properly. Because the strategy calculates position sizes based on the account equity (1% in this case) and on relaunch will try to sync 26 contracts as the account equity has increased. I'm not sure if it syncs 25 and then buys another - or on a loss syncs only 24.

    FYI - on my end NT blows up almost every weekend. Not sure why, I'm just that lucky. In any case - any input, suggestions, thoughts would be appreciated. I think my approach (persistence of open campaign's units) will fix this problem but I want to make sure before I proceed with implementation.

    Thanks!

    #2
    Hello molecool,

    Thank you for your post.

    This is affected by the settings SyncAccount, On starting a real-time strategy, and also by your strategy logic. Let's not factor in strategy logic first.

    Let's say based on your information we are using SyncAccount = True, so our strategy immediately forces it's position to the account. This means if the strategy determined 26 contracts, it's going to force 26 long or short to the account for the instrument being traded by the strategy.
    So if you strategy determines the contract size and you run SyncAccount = True it will perform as you detailed.
    If we run 'immediately submit live working historical orders' we will also see orders that the strategy determines it would have submitted actually submitted to the account on start up of the strategy.

    So while these settings affect the strategy on start up, it is highly dependent on what the strategy has calculated as the orders and positions that are needed.

    What are you running for the option 'Set order quantity'?

    Comment


      #3
      Yes, of course sync account position is set to true - that's obviously necessary. You mentioned 'immediately submit live working historical orders' - where is that set?

      In any case - can you please confirm to me that persisting unit sizes in the context of using dynamic position sizing (e.g. R based) is the proper approach on re-syncing? I just want to be able to pick up where a strategy left off upon restart or crash.

      Thanks in advance.

      Comment


        #4
        Hello molecool,

        Thank you for your response.

        The 'On starting a real-time strategy' settings such as 'Immediately submit live working historical orders' are available under Tools > Options > Strategies > NinjaScript.
        For information on these options please visit the following link: http://www.ninjatrader.com/support/h..._positions.htm

        I would not say there is one correct approach. If you are dynamically updating your position size based on a calculation, that is fine but how it effects the strategy on re-start may be different than you expect.
        The strategy will re-calculate it's positions and orders when started up again. This means if the R-Based calculation determines a different size than what you had when the strategy was shut down then it will adjust based on this calculation.

        You may wish to Print() the value of your contract sizing calculation to pull this information on start up (in OnBarUpdate()) of the strategy: http://www.ninjatrader.com/support/h.../nt7/print.htm

        Comment


          #5
          Originally posted by NinjaTrader_PatrickH View Post
          Hello molecool,

          Thank you for your response.

          The 'On starting a real-time strategy' settings such as 'Immediately submit live working historical orders' are available under Tools > Options > Strategies > NinjaScript.
          For information on these options please visit the following link: http://www.ninjatrader.com/support/h..._positions.htm
          Right that one has been set to 'immediately' as I want my strategies to be in sync with my account.

          Originally posted by NinjaTrader_PatrickH View Post
          I would not say there is one correct approach. If you are dynamically updating your position size based on a calculation, that is fine but how it effects the strategy on re-start may be different than you expect.
          The strategy will re-calculate it's positions and orders when started up again. This means if the R-Based calculation determines a different size than what you had when the strategy was shut down then it will adjust based on this calculation.
          No, what you are describing is EXACTLY what I am expecting and in fact it's the issue I have been describing. I realize that you guys are looking at many forum posts and trouble tickets each day and therefore some details may get lost in the noise - or perhaps I didn't properly explain myself. But in fact that was my point - if I relaunch my strategy and want it to be in sync and if my account size has changed then it will invariably use a different position size.

          My question to YOU guys is how Ninja correlates the differences. If I originally was long 155,500 units in EURUSD and after restart my strategy would take 156,000 then what would happen exactly? Does it buy another 500? Or does it close out the original position and then buy 156,000 all over again?

          Originally posted by NinjaTrader_PatrickH View Post

          You may wish to Print() the value of your contract sizing calculation to pull this information on start up (in OnBarUpdate()) of the strategy: http://www.ninjatrader.com/support/h.../nt7/print.htm
          I use print excessively but I fail to see how an automated strategy would benefit from that unless I would produce a parameter field. My strategy does not use default position sizing, it calculates the position size before taking an order by calculating the R percentage (i.e. 1%). My current approach entails persisting the entry date and unit size to file. On relaunch I read that file and then use that unit size assuming the date and entry limit price are a match.

          I hope this makes more sense - again, if not we should probably chat on the phone or via skype so that I can properly explain what I'm doing.

          Comment


            #6
            Hello molecool,

            If the Account Position does not match your Strategy Position, NinjaTrader will submit a market order(s) to reconcile the Account Position to match your Strategy Position. The strategy will then begin managing your Strategy Position immediately - taken from 'Syncing Account Position - Immediately submit live working historical orders, Sync account position = true' at the following link: http://www.ninjatrader.com/support/h..._positions.htm

            This means in your example it would NOT close the position and then re-open it. It would submit 500 to bring the account to the strategy position.

            Comment


              #7
              Originally posted by NinjaTrader_PatrickH View Post
              Hello molecool,

              If the Account Position does not match your Strategy Position, NinjaTrader will submit a market order(s) to reconcile the Account Position to match your Strategy Position. The strategy will then begin managing your Strategy Position immediately - taken from 'Syncing Account Position - Immediately submit live working historical orders, Sync account position = true' at the following link: http://www.ninjatrader.com/support/h..._positions.htm

              This means in your example it would NOT close the position and then re-open it. It would submit 500 to bring the account to the strategy position.
              Alright - this is what I suspected, thanks. I assume if it's 500 units too many it will close out that amount, correct?

              Comment


                #8
                Correct molecool.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                558 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                324 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                545 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                547 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X