No announcement yet.

Partner 728x90


Restarting a strategy after weekend....

  • Filter
  • Time
  • Show
Clear All
new posts

    Restarting a strategy after weekend....

    Hi NT.

    I'm aware of all the info about strategies, syncing accounts...etc, but I'd like to bring here a practical case so I can confirm all settings are correct.

    Let's say that I have an automated strategy that might hold a position several days. Any opened position will always have a protective stop loss order tied to. Now, we arrive at the weekend with an active opened position. As it's known, mostly brokers' connections are broken during the weekend, so obviously, we need to sync positions and orders seamlessly in order to allow our strategy continues to be as it was last Friday. In order to do that, my settings for Strategy, Syncing, Positions, Orders...etc are:

    - On Tools \ Options \ Strategy \ Ninjatrader --> I got unselected boxes of "Cancelling orders when a Strategy is disabled, both of them.
    - Immediately submit live working historical orders, Sync account position = true

    I had thought that this general set would be good enough to achieve perfect sync and reactivation, but sometimes I got order cancellations, flatten positions, reopened positions...etc.

    Do you have any comment, ideas or suggestions?
    Last edited by pstrusi; 07-15-2019, 10:42 PM.

    Hello pstrusi,

    Thank you for the question.

    I always find it helpful to walk through the description of the sync option being used to see if your strategy fits its guidelines. It is possible you are just seeing the sync behavior work correctly based on what it observed in your script.

    Here are the general steps the sync action takes:

    Any active orders on the account previously generated by the strategy that does not match* an active strategy order will be cancelled. Should the strategy be unable to cancel and receive confirmation on the cancellation of these orders within 40 seconds the strategy will not start and an alert will be issued.

    This is an important step and relies on how you coded your strategy. The important note is the first sentence, if an active order which the strategy previously generated does not match it will be cancelled. What this entails is that your strategy performed virtually the same historically up to that order when you re enabled it. This is where it can become tricky in case your strategy performs differently in historical versus realtime. If the strategy can no longer reach the same conclusion to place this order historically while processing, it is cancelled.

    An order needs to match all of the criteria:
    * A previously generated order is considered to match an active strategy order when the order action, order type, quantity, limit price, and stop price are exactly identical.
    The remaining steps are pretty straight forward after the orders have been compared. The remaining orders are matched and mapped to the strategy. If the strategy had active orders which were not pared, their are submitted and then the account sync occurs to bring the account in sync with the current strategy position.

    • The matching active orders on the account will then be mapped to the active strategy orders
    The matching active orders on the account will then be mapped to the active strategy orders
    • Any remaining active strategy orders that cannot be successfully paired will be submitted live and the strategy will begin managing your Strategy Position assuming your Account Position is in sync with it.

    If the strategy somehow is performing differently when re enabled, what you are seeing is likely expected. In some cases this could be caused by data changes, for example if missing data had been added to the instruments historical dataset. If the data is reloaded this may change indicator calculations or other values slightly causing changes in order placement when re enabled.

    You may try and download playback data for this timeframe where you saw this happen. If you run through the period before the weekend and can reach the same results, you may be able to recreate the event to test why the logic is working differently. You could play up to the point where you disconnect, and just disable the script. Then re enable it at the time you normally do once playback has played forward enough to see if that happens.

    I look forward to being of further assistance.

    Last edited by NinjaTrader_Jesse; 07-16-2019, 07:31 AM.
    JesseNinjaTrader Customer Service


    Latest Posts


    Topics Statistics Last Post
    Started by pjsmith, 01-03-2022, 10:38 AM
    3 responses
    Last Post brucerobinson  
    Started by Spank, Yesterday, 04:32 AM
    2 responses
    Last Post brucerobinson  
    Started by onlinebusiness, Today, 02:31 AM
    0 responses
    Last Post onlinebusiness  
    Started by kainermy, Today, 02:08 AM
    0 responses
    Last Post kainermy  
    Started by bomberone3, 10-16-2017, 12:16 PM
    11 responses
    Last Post Spank
    by Spank