Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy and Chart completely hang if ChangeOrder price issues.

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

    Strategy and Chart completely hang if ChangeOrder price issues.

    I'm writing an unmanaged order manager and testing it with a simple reversal Calculate.OnBarClose strategy. With RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;

    The strategy takes an initial long or short position and thereafter the position is reversed by an opposite entry order which is initially placed in OnExecutionUpdate

    (_LongEntryFilled = cumulative count of contracts filled and/or partfilled. _trailingShort[0] is double price below last.

    Code:
                if     ( _shortEntryStopMar****rder==null)
                {
                       SubmitOrderUnmanaged(0, OrderAction.SellShort, OrderType.StopMarket,  _longEntryFilled, 0.0,_trailingShort[0], "", "EntryShort");
                }
                else
                {
                        ChangeOrder(_shortEntryStopMar****rder,  _longEntryFilled, 0.0,_trailingShort[0]);
                 }
    Then in OnBarUpdate the active order is adjusted bar by bar as the trailingshort price changes:

    Code:
                if     ( _shortEntryStopMar****rder!=null && Position.MarketPosition == MarketPosition.Long)    
                {
                      if (_shortEntryStopMar****rder.StopPrice < _trailingShort[0] && Close[0] - TickSize  >= _trailingShort[0])
                      {
                           ChangeOrder(_shortEntryStopMar****rder, _contracts  + Position.Quantity,  0.0, _trailingShort[0]);
                      }
                }
    If the open of the following bar gaps above (or below) the ChangeOrder price, results in an error message:

    Click image for larger version  Name:	Error.PNG Views:	0 Size:	8.7 KB ID:	1089494


    This is fair enough, however if the "OK" is not clicked quickly the entire chart just freezes.

    I've found to recover one way is to kill the entire NinjaTrader process stack or to cancel the last entry order from another window, e.g. Superdom. If I am able to cancel the entry order, then the chart spools the buffered ticks but the strategy is dead.

    Any advice on how to add code to avoid encountering this error or better yet to handle it? Is there existing reference code to properly handle rejects somewhere? I see in OnOrderUpdate https://ninjatrader.com/support/help...t8/?charts.htm we get the state and error code which seem to be generic, like ErrorCode.OrderRejected. However Ninja obviously is receiving more detailed information in order to determine to present the above error message.

    Where is this info exposed? I'm assuming its passed back from the broker (simulator) via the OnOrderUpdate string comment field.

    If so, can you provide a list of possible string values by SIM101 and NinjaTrader Continuum?

    Will proper handling of the rejection obviate the need to present the user with an error message, that is to not stop the UI / strategy?
    Last edited by lavalampmj; 03-05-2020, 04:54 PM.

    #2
    Hello lavalampmj,

    Thanks for your post.

    The strategy can ignore these errors with RealtimeErrorHandling set to IgnoreAllErrors, but there is not a supported way to suppress the error messages.

    The chart freezing would not be something we would expect to see. Could you attach a simplified script that takes this approach and encounters this issue on NinjaTrader 8 Release 21? If we have a simplified working test that demonstrates the issue, we can use it to file a report. You could post the script here, or you can email it to me at platformsupport [at] ninjatrader [dot] com with the text "Attn Jim 2445435" and a link to this thread. The script does not need to have complex logic or any real entry signals, it should just have enough order submission logic where we can hit this behavior on our end with NinjaTrader 8 Release 21.

    I look forward to being of further assistance.

    Comment


      #3
      I'll send you a script via email. I'm on 8.20 not 8.21

      Having errors being displayed (with the result of freezing charts) means the platform cannot be used for 23x5 trading. Its a big deal for me, probably a show stopper. If a user has to click OK at 3:00am its just not going to happen, further the notion of RealtimeErrorHandling.IgnoreAllErrors become pointless because it does not implement the desired functionality. I'm happy with using "unsupported" methods if there are some available to suppress the error msg. Please advise here or by email.

      It would be helpful to me and perhaps others who wish to write their own unmanaged order handlers, to correctly process order rejects.

      In this specific case I might wish to send a market order upon the reject or adjust the price and resubmit. There are probably many many reasons for an order rejection.

      In order to intelligently handle rejects, I need to build some logic for the various reject cases. I believe that contextual "why" data is passed in the last string comment field by the broker in OnOrderUpdate event.

      Can you post all of the possible strings sent from the broker (in my case) NinjaTrader Continiuum and SIM101. Thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      50 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      126 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X