Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ConnectionLost and Order Handling

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

    ConnectionLost and Order Handling

    Hi Ninja Team,

    I just had a Strategy submit an order while the OrderServer was ConnectionLost. In the Options tab I have Keep Running selected. The Strategy shut itself down. Is that expected bahavior for the Keep Running option? What would the Recalculate Option have done any differently?

    Here is the print of the Output Window (I run a Strategy called ConnectionMonitor to monitor connections).

    PHP Code:
    **NT** Strategy 'ConnectionMonitor/1f228ea00fc046a89579cd547db38456' lost order connection but will keep running.
    2010-07-02 13:22:32 Connection 'Hosted' Order ServerConnectionLostPrice ServerConnected.
    **
    NT** Strategy 'Module1c/d3a9ed45629e403a905c622d00539237' lost order connection but will keep running.
    **
    NT** Strategy 'Module1c/9f32f52bb72340b58ce4b7d011b7ee50' lost order connection but will keep running.
    **
    NT** Strategy 'ConnectionMonitor/1f228ea00fc046a89579cd547db38456' lost price connection but will keep running.
    2010-07-02 13:23:34 Connection 'Hosted' Order ServerConnectionLostPrice ServerConnectionLost.
    **
    NT** Strategy 'Module1c/d3a9ed45629e403a905c622d00539237' lost price connection but will keep running.
    **
    NT** Strategy 'Module1c/9f32f52bb72340b58ce4b7d011b7ee50' lost price connection but will keep running.
    2010-07-02 13:23:38 Connection 'Hosted' Order ServerConnectionLostPrice ServerConnected.
    2010-07-02 13:25:14 STRATEGY Module1cES 09-10 LONG signal generated with BID/ASK at1023.75/1024 AllTrades CumProfit: $0
    **NT** Strategy 'Module1c/d3a9ed45629e403a905c622d00539237' submitted an order that generated the following error 'UnableToSubmitOrder'Strategy has sent cancel requestsattempted to close the position and terminated itself.
    **
    NT** Disabling NinjaScript strategy 'Module1c/d3a9ed45629e403a905c622d00539237'
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    2010-07-02 13:25:14 TERMINATING Strategy Module1cES 09-10
    2010
    -07-02 13:25:14 ES 09-10 AllTrades CumProfit: $0
    2010
    -07-02 13:25:14 ES 09-10 Market PositionFlat
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
    I'm happy it did what it did, but I'm now wondering if I should code a filter where status Connected needs to be true before an order is submitted. Is that something that should be handled by NT internally?

    #2
    MXASJ, yes this is expected the KeepRunning left the strategy running even though you did have a Connection Loss event, of course as it tried to submit an order it failed and then shut down as a consequence (default error handling, see RealtimeErrorHandling in the helpguide).

    Recalculate would attempt to recalculate your strategy's position once the connectivity is fully back up (and held up for 'RestartDelaySeconds').

    You could check for the OrderServer connection being ok before submitting an order if you choose to KeepRunning on disconnects.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      The Zenfire disconnect thing has been keeping me busy. I've added this before OnBarUpdate():

      PHP Code:
      protected override void OnConnectionStatus(ConnectionStatus orderStatusConnectionStatus priceStatus)////////// 
      {//Open OnConnectionStatus

      badPriceDataFeed priceStatus;
      badOrderDataFeed orderStatus;

      if (
      badPriceDataFeed == ConnectionStatus.Connected && badOrderDataFeed == ConnectionStatus.Connected)
      {
      connectionOK true;
      }
      else 
      connectionOK false;

      }
      //CloseOnConnectionStatus 
      And this at the start of OnBarUpdate():

      PHP Code:
      if (connectionOK == false)
      {
      Print(
      DateTime.Now " OnBarUpdate paused OnConnection.Disconnected. " Instrument.FullName);
      return; 
      //Return out of OnBarUpdate if disconnected.

      My question is... should the Strategy still send orders if I'm disconnected and I'm using managed orders such as EnterLong(), SetTrailStop(), etc etc, and is the BarsInProgress index something I need to watch for multi series strats?

      Thanks!

      Comment


        #4
        MXASJ,

        Yes, orders will still be submitted when you are disconnected. Default behavior is that once you run into such a scenario is when the strategy will be halted though. For instance, NT will let you continue running the strategy if you lost connection to the order feed. This does not matter as long as you get reconnected before your next order submission. If you submit an order action prior to reconnecting to the order feed then problems arise since the order submission never made it to the brokerage and as such the strategy will be stopped at that point in time. The benefits of being able to continue running the strategy through a disconnect is to have an opportunity of not needing to restart the strategy and recalculate everything which can result in different positions.

        The BarsInProgress is definitely something you would need to watch in a multi-series strategy. It heavily influences your trade logic.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by patrickmlee007, Today, 09:33 AM
        2 responses
        15 views
        0 likes
        Last Post patrickmlee007  
        Started by magnatauren, 08-15-2020, 02:12 PM
        5 responses
        206 views
        0 likes
        Last Post RaddiFX
        by RaddiFX
         
        Started by rene69851, 05-02-2024, 03:25 PM
        1 response
        21 views
        0 likes
        Last Post rene69851  
        Started by ETFVoyageur, Yesterday, 07:05 PM
        5 responses
        45 views
        0 likes
        Last Post ETFVoyageur  
        Started by jpeep, 08-16-2020, 08:31 AM
        13 responses
        487 views
        0 likes
        Last Post notenufftime  
        Working...
        X