• 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

What happens if I submit an order on the wrong side of market?

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

    What happens if I submit an order on the wrong side of market?

    Hi there,

    I'm working on a strategy. I'm concerned that if I submit a stop-market order on a fast tick chart that price might have moved beyond the order point before the order is placed.

    So I would like to understand. If I try to place a Stop Market Buy Order BELOW the current price on a Live account, does this result in an error, or does it get filled at the market?

    I've been trying to make an unmanaged strategy for about the last 2 hours to simulate this using the Ninjatrader SIM account but I can't get it to submit the order. The debugger says there's an order object and it says its OrderState is "Filled", but there's nothing in the orders tab and nothing on the chart, trace or logs. Not sure what I'm doing wrong, but just need to understand what to expect when this happens.

    Many thanks

    #2
    Hello kevinenergy,

    Thanks for your post.

    A stop market order placed or moved to the other side of the market will result in an order rejection in live scenarios. NinjaTrader's simulation engine will mimic this.

    If the market moves before the order gets processed by the exchange and a rejection results, it would be possible to have the strategy handle the rejection by having RealtimeErrorHandling set to IgnoreAllErrors and then trapping the occurrence in the OnOrderUpdate() method. I've included documentation links for these items below.

    OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm

    RealtimeErrorHandling - https://ninjatrader.com/support/help...orhandling.htm

    I've also included an example Unmanaged strategy that can be used as a reference while you are developing your own strategy.

    If there is anything else we can do to help, please let us know.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Hey Jim,

      thanks thanks very much for the advice and samples. I've decided to stick with Managed Strategies for now until I figure out what I'm doing.

      Does the same advice stand on Managed Systems: I.e I'm calling EnterLongStopMarket, EnterShortStopMarket or SetStopLoss on a managed strategy and the market moves the wrong way? I would have IngnoreAll Errors = true. And handle the rejection in the OnOrderUpdate and submit a market order there.... or does the managed order system do this for me?

      Thanks again.

      Comment


        #4
        Hello kevinenergy,

        The only way NinjaTrader handles rejections on its own is to panic and Stop the strategy, Cancel pending orders, and Close any open positions as defined by the RealtimeErrorHandling setting. The Managed Approach and the Unmanaged approach do not offer different behaviors here.

        If you want a different behavior, it would have to programmed in OnOrderUpdate() using RealtimeErrorHandling.IgnoreAllErrors or RealtimeErrorHandling.StopCancelCloseIgnoreRejects .

        Please let us know if you have any additional questions.
        JimNinjaTrader Customer Service

        Comment


          #5
          Hey Jim.

          Still working on my error handling for stops. I am able to get it working for a new stop-loss that gets submitted and has a status of "Rejected". However if I try to move an "Accepted" stop loss and the market moves beyond the new price before the order is accepted then the strategy produces an error message, but the stop loss isn't given a state of "Rejected". It remains as "accepted" and at the original price.

          As far as I can make out the OrderState transition in this scenario is ChangePending, ChangeSubmitted, Accepted - which is the same transition flow for a valid Order Change.

          How can I capture a failed stoploss change so that I can close the position at market?

          Update: I've found out that simulated stops close at the market when they're moved to the wrong side of the position; this will allow me to backtest and optimize my strategy without it throwing errors. However I would like to find a solution that uses hard stops for live running.
          Last edited by kevinenergy; 09-11-2018, 09:03 AM.

          Comment


            #6
            Hello kevinenergy,

            Rejected is a terminal order state which would be seen if the order is no longer active. Moving a stop loss to a new level and having the change refused may not result in a rejected order, but will keep the order active at the previous level.

            The information you have seen could be used to identify this occurrence. For example, when you change your stop loss, you could set a bool and then check if the change was successful in OnOrderUpdate(). If your bool is true (stop loss is changed) and then you see order updates for your stop loss report ChangePending, ChangeSubmitted, and Accepted, with the associated stop price moving from the old price, to the new price, and then back, you have successfully identified the change being refused.

            I added the following print in OnOrderUpdate to test this which made the occurence more identifiable:
            Print(order.Name + " " + orderState + " " + stopPrice);

            Output:
            MyStop ChangePending 2884
            MyStop ChangeSubmitted 2886.5
            MyStop Accepted 2884
            If there is anything else we can do to help, please let us know.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rickyblah12, Today, 01:01 PM
            1 response
            11 views
            0 likes
            Last Post Erwin Beckers  
            Started by dadarara, Today, 12:18 PM
            0 responses
            8 views
            0 likes
            Last Post dadarara  
            Started by joemiller, Today, 07:33 AM
            2 responses
            12 views
            0 likes
            Last Post joemiller  
            Started by TheGameOfProbabilities, 07-18-2019, 06:56 AM
            7 responses
            38 views
            0 likes
            Last Post DaveS
            by DaveS
             
            Started by claxxical, Yesterday, 10:00 PM
            0 responses
            13 views
            0 likes
            Last Post claxxical  
            Working...
            X