Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy restarted after price connection lost, leaving existing position unclosable

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

    Strategy restarted after price connection lost, leaving existing position unclosable

    My NT log reports
    "NinjaTrader Continuum (Live): Primary connection=Connection lost, Price feed=Connection lost"
    after my strategy had established a long position. This interruption disabled, and then reenabled, my strategy, which would normally have closed the position at a price that was realized later in the session (after the interruption) but the position was never closed.

    My questions are:
    1. Was this failure to submit an appropriate sell order due to the fact that my strategy's start behavior is set to WaitUntilFlat?
    2. If so, then which start behavior option would best allow the strategy to continue functioning as if the interruption had not occurred?
    3. If I change the start behavior option, do I need to remove the following lines (at the start of code section OnBarUpdate) that are intended to ensure processing of only realtime events?
    if (State == State.Historical)
    return;
    if (BarsInProgress != 0)
    return;
    if (CurrentBars[0] < 1)
    return;



    #2
    Hello Red_70,

    Thank you for your post.

    Yes, this would occur if you were either using Wait Until Flat or Immediately Submit. Both of these start behavior options would not check the account position at the time the strategy is restarted and simply start submitting orders as they assume your account is in the position the strategy is (i.e. Flat, since you're not submitting anything historically). When the strategy restarted it simply started submitting orders as if the account position was in fact flat.

    You can avoid this by using Wait Until Flat, Synchronize Account or Immediately Submit, Synchronize Account as the strategy start behavior. This would see the open position and submit a synchronization order to bring the position back to flat before further orders are submitted in real time. This would not require you to remove the lines that cause processing of only real time events.

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Hi Kate,

      Thanks for your reply.

      According to the NT8 support guide, "Wait Until Flat, Synchronize Account" and "Immediately Submit, Synchronize Account" both submit market orders to reconcile the account position to the strategy position. Ideally, I'd like to avoid the submission of market orders to close existing positions, relying instead on my strategy's logic to check for the existence of a position, via
      if (Position.MarketPosition == MarketPosition.Long) {...}
      before submitting a limit order to close.

      Could I use the "Adopt Account Position" start behavior to achieve this goal? According to the NT8 support guide, "Adopt account position will only be available if the developer of a strategy has programmed the strategy to be aware of the real-world position." Does the above test for the existence of a long position satisfy this requirement? If not, how can I implement "Adopt Account Position"?

      Comment


        #4
        Hello Red_70,

        Thank you for your reply.

        You could do that as well, yes. Here's a simple example script that will exit an existing long position on the account when the strategy is enabled. You could modify this to submit protective orders for the position instead if you like.

        Please let us know if we may be of further assistance to you.
        Attached Files

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        65 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        139 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X