Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Handling Strategy Disconnections (in NT7)

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

    Handling Strategy Disconnections (in NT7)

    Guys, in NT7, we are running strategies with Sync Account Position = True, an ATM managing the stops and targets, and the following settings under Options > Strategies > NinjaScript:

    - Wait until flat before executing live

    - Disconnect delay seconds: 15
    - Number of restart attempts: 4
    - Restarts within x minutes: 5
    - Handling: Recalculate

    - Cancel entry orders when a strategy is disabled (checked)
    - Cancel exit orders when a strategy is disabled (checked)

    With these settings, I have three questions:

    1) Suppose our strategy places an entry order and we lose our internet connection and the order is filled while the connection is lost. Then suppose the connection is restored in less than 15 seconds (the Disconnect delay period), so when the strategy resumes there is a naked position, with no stop or target in place. With the above settings, will NT7 (external to the strategy), submit a market order to exit the position when the connection is restored? If so, then will we need to tell the strategy that the entry order it placed is no longer valid? (I assume so.)

    2) Suppose we lose our internet connection after the entry order is filled and a stop and target are already in place with broker, managed by our ATM. Then the connection is restored in less than 15 seconds (the Disconnect delay period), and when the strategy resumes there is a position, a stop, and a target previously managed by the ATM. Will NT7 exit the position with a market order and cancel the open stop and target, external to the strategy? Again, if so, I assume we will need to tell the strategy to ignore the trade and reset it's AtmStrategyId.

    3) Finally, under these same two scenarios, if the Disconnect Delay is exceeded and the strategy is stopped and not just paused, will NT7 still exit positions and cancel the outstanding orders with the settings above when the connection is resumed?


    If I understand the help files, the answer to the above questions would be yes, but I'd like to confirm that I understand correctly.

    Thank you again for your help.

    Best wishes,

    Light

    #2
    Hello Light,

    Thank you for the post.

    In this case, I believe all of these questions will relate specifically to if the strategy needs to recalculate or not. The StartBehaviour only happens once when the script is started or is calculating.
    I believe the following note would be relevant to these questions:

    Recalculations will only occur if the strategy was stopped based on the conditions below. Should the connection be reestablished before the strategy was stopped, the strategy will continue running without recalculating as if no disconnect occurred.
    In your first case, if the script does not need to recalculate based on the used settings, the platform would not try to reconcile the account as the strategies start behavior would not be run.

    In the second case, you noted that is also less than the disconnect seconds so no reconciliation would occur as the strategy would just be paused for that time and then continue running.

    In the third case, the strategy would follow the disconnect rules set or recalculate. If the Account Position is not flat, NinjaTrader will submit a market order(s) to reconcile the Account Position to a flat state based on the start behavior used.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jesse. I think I understand now... the command to get NT7 to reconcile the strategy with the account is called during the Initialize() method, so unless the strategy is stopped and restarted, NT7 will not send orders to the broker to flatten positions. Is that right? If so, we'll just stop the strategy and restart it in order to call Initialize() and reconcile when needed.

      Thanks again...

      Light

      Comment


        #4
        Hello Light,

        Yes, the logic that happens for the start behavior only occurs when you first start the script or it needs to recalculate.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by traderqz, Today, 12:06 AM
        2 responses
        3 views
        0 likes
        Last Post traderqz  
        Started by RideMe, 04-07-2024, 04:54 PM
        5 responses
        28 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by f.saeidi, Today, 08:13 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by DavidHP, Today, 07:56 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by kujista, Today, 06:23 AM
        3 responses
        11 views
        0 likes
        Last Post kujista
        by kujista
         
        Working...
        X