• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Restarting a strategy after weekend....

Collapse
X
  • 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?
    Thanks
    Last edited by pstrusi; 07-15-2019, 10:42 PM.

    #2
    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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by erichuff, Today, 04:53 AM
    1 response
    24 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by stevenev1, Today, 01:43 PM
    0 responses
    8 views
    0 likes
    Last Post stevenev1  
    Started by shinuvu, Today, 11:05 AM
    3 responses
    18 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by Hagar, Yesterday, 07:12 PM
    2 responses
    20 views
    1 like
    Last Post Hagar
    by Hagar
     
    Started by PBreen, Today, 11:59 AM
    2 responses
    13 views
    0 likes
    Last Post PBreen
    by PBreen
     
    Working...
    X