Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Double order created by stop right before cancel

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

    Double order created by stop right before cancel

    I ran an automated strategy that just so happened to have conditions where the strategy tried to execute a reversal (sell to exit; then sell to enter a new short) just as my long was getting stopped. So I get this sequence of events:

    -Enter long
    -Submit market orders for two shorts, one to close the long, and one to enter the next trade
    -Before step two is fully processed, Long's stop is filled (I'm guessing this is what happened. I guess I don't know for sure).
    -The Close Position's order is filled, but now it's entering a new trade because there's no longer a position to close
    -The short that was supposed to open this position now opens a second position. This one had no stop!

    Is there a way to prevent this? Or recognize it and back out of the second position? I'm worried that if the strategy submits the order before the first position is closed, it might not realize it's entering twice. And I can't recreate the problem to test in Playback assuming it's an internet lag issue.

    Thanks
    Last edited by krpkevin; 11-30-2017, 05:17 PM.

    #2
    Hello krpkevin,

    Thanks for your post and welcome to the NinjaTrader forums!

    You can prevent by testing to see if you are already in a position before placing an order.

    For example, as part of your entry conditions you could use:

    if (Position.MarketPosition == MarketPosition.Flat && (your entry conditions...))

    Reference:
    https://ninjatrader.com/support/help...etposition.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks, but I don't think that would work. The issue isn't with placing the order; it's with completing the order.

      Let's ignore the entry and just focus on closing the Long. How do I close the Long position when it's about to get stopped?

      The Long is open. The strategy submits a close position order, but before it gets across the internet, or whatever it's doing, the Long is stopped. Then, the close order "arrives", but there's nothing left to close, so it opens a short (since a Long close is really just a Short).

      Now I'm short when I should be flat.

      How do I handle this?

      Comment


        #4
        Hello krpkevin,

        Thanks for your reply.

        The prevention means would be your code evaluating current price to your stop price and close conditions price and allow one or the other to operate but not both. In other words, maintain a larger price difference between where the stop exists and where the close condition is.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Yep I'm with you. That was my thought as I kept thinking about this more. Thanks for the confirmation!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by soon123, Today, 12:18 AM
          1 response
          19 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by space_trader, Today, 12:52 AM
          1 response
          20 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by ybhx0315, Yesterday, 09:06 PM
          0 responses
          20 views
          0 likes
          Last Post ybhx0315  
          Started by parkinsonbr, Yesterday, 08:23 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by fxRichard, Today, 04:35 AM
          2 responses
          14 views
          0 likes
          Last Post fxRichard  
          Working...
          X