Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancelled stop loss order showing as 'Cancelling' in order tab

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

    Cancelled stop loss order showing as 'Cancelling' in order tab

    Hi,

    I have a strategy running with FXCM as my broker. Last night the strategy went short on a few positions. Then an exit signal was given and my strategy exited the short positions and entered into a few long positions.

    The issue was that one of the stop loss orders didn't cancel correctly on the original short positions when the underlying position was closed. An error message popped up and said the order wasn't a multiple of 1000. The order was actually a order of 1000 being 57000. You can't place an order with fxcm the order is of 1000. Because of this the strategy then bought all the positions that i had just closed again. i read on the forum here that if MarketPosition is not flat and you buy a position in the opposite direction to what you have it will then issue a closed position order and cancel out the other positions.

    The problem here is my strategy had already closed out my position then ninjatrader bought all the positions again. So now I had twice as many long positions as i was after which resulted in a loss twice what it should have been. For next time I will add in a check not to add positions until the MarketPosition is Flat.

    What I would like to know is if i have closed a position and then ninjatrader for some reason can't close out the stoploss order associated with that position. Is there any way that I can then force the cancellation of the stop order so my strategy can then be marketposition.flat. When i checked my account in fxcm the stop order had been cancelled. It was just showing as a state of 'Cancelling' when in Ninjatrader order tab.

    Cheers,
    Mark

    #2
    I think I have found the issue. I'm exiting a short position and entering a new long position inside OnBarUpdate(). This works in demo but in live its triggering the Close Position to buy to cover the position again after I've already closed it creating 2 times the amount my long position should be. What I will do is in status realtime set a flag that it will go over OnBarUpdate again until the MarkPosition is flat then buy the new positions. I'm not sure if the Cancelled stop loss order showing as 'Cancelling' is causing the issue.

    Comment


      #3
      Hello,

      Thank you for the post.

      Based on the description, it sounds like you are simply running into an order of operations problem. The Exit and Entry happening in the same call to OnBarUpdate would certainly cause what you have described as the Position would not be updated between the two calls at this point.

      The Enter statement would try to Reverse the position, where the Exit would try to also exit the same position in this situation.

      By executing these two statements in two calls to OnBarUpdate the problem should no longer exist. I can't confirm if anything else in the logic may be at fault for any of the items mentioned specifically, but I can say this specific scenario would cause what you have described.

      Regarding the Cancelled order, I would likely need to review the logic to understand what may be happening surrounding that. If this still persists after making the changes, I would suggest to try and reduce the code as much as possible and then upload the script. I could take a look and see if anything sticks out specifically surrounding the cancelled order.

      I look forward to being of further assistance.

      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