Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reversal - Close position order left at "working" status

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

    Reversal - Close position order left at "working" status

    Hi

    I am running backtests on a strategy that has both long/short entries and long/short exits orders

    in some circumstances a long exit coincide with a short entry (or a short exit with a long entry) which results in a reversal of position. This is actually what I intended in my strategy.

    In a reversal situation, NT issues by itself a "close position" order on its own.

    Since I already exited the position via my programmed exit orders, the "close position" order seems to be stuck in "working" status when looking in the orders tab of the backtest results in strategy analyser.

    Is this normal behavior for the "close position" orders to be stuck in "working status" ?
    Shouldnt the "close position" order be cancelled by NT instead when the position to be closed is already exited via an order in the strategy itself.

    For now it does not seem to affect the back test results to have stuck "close position" orders like this. Is this behavior going to be a problem in real trading since the "close position" orders are still working and would thus add positions to the real account ? if yes what would be the solution to this behavior, can we tell NT to not issue "close position" orders on reversal situations ?

    #2
    qewcool,

    You should never program it like this as it can cause issues depending on which order makes it to the exchange first and other race conditions. If you wish to reverse, you should not submit your own exit order. If you do have an exit order you want to submit and would like to proceed in this path, you should not submit your Enter() order until your Exit() order has returned back with a terminal state.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      thanks for the reply

      The problem is my exits orders are not specifically for a reversal situation. They are general exit orders part of the strategy.

      It just happens that in some circumstances both exits and entries on the opposite side conditions will be fulfilled on the same bar.

      So I dont really have a choice of not issuing an exit order.

      Does it mean that I either have to :

      1) check for the reversal case in my code and write an exception for it (I would like to avoid this actually). It seems very cumbersome to have to do that.

      2) check for the exit conditions first in the code and then check for the entry conditions so that the exit order is going to get sent before the entry order ?

      do you have reference code or example on how it should be done ?

      Comment


        #4
        qewcool,

        You can proceed either way. Way I would do it is just check for pre-existing orders. If I already have a running Exit order, I will not submit a new Entry till that exit is terminal. Vice versa too. If I have a working Entry order, I will not submit an Exit order to close the same position that is already going to be reversed to prevent overfills.

        Unfortunately I do not have sample code for this per se, but to do this you can track order status and such through OnOrderUpdate() and OnExecution(). http://www.ninjatrader-support2.com/...ead.php?t=7499
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          OK

          I did the checking for no working entry orders before checking of exit conditions in the OnBarUpdate part and it seems to work.

          The reversal situations are exited via the close position orders sent by NT since i dont send exit orders in that situation anymore.

          seems to work and I dont see the close position orders stuck in working status anymore on the orders tab on the backtest results.

          Thanks for the quick replies.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          627 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          359 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          562 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          568 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X