Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetStopLoss cancelling existing entry orders on opposite side of the market

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

    SetStopLoss cancelling existing entry orders on opposite side of the market

    Hi,

    I have a strategy that can call EnterLongLimit and EnterSellLimit at the same and both orders will be outstanding until one of them is filled. I also call SetStopLoss and SetProfitTarget for both.

    If my SellLimit order is filled, my stop and profit target are sent correctly, but what I'm noticing is that if my StopLoss for that sell is filled, my existing Limit order is cancelled.

    From the logs, I'm short two contracts with a working LongLimit and I get the following two executions from my StopLoss. I see that Market Position is Long, which isn't correct at any point. The MarketPosition of Long could be what is cancelling my Existing Long Limits as I have some code to that effect, but I'm not sure why this is the case.

    LOGS:
    Execution='xxxxxxx' Instrument='xxx' Account='xxxx' Exchange=xxxx Price=1887.25 Quantity=1 Market position=Long
    Execution='xxxxxxx' Instrument='xxx' Account='xxx' Exchange=xxx Price=1887.25 Quantity=1 Market position=Long

    Can anyone help clarify what is happening or why my MarketPosition is thought to be LONG when it should be Short 1 on the first fill, Flat on the second fill?

    Thank you !

    #2
    Hello,

    Thank you for the question.

    I wanted to check, are you trying to submit a bracket entry order that has associated stops? If so the managed approach in general is not suited for this type of entry, the Unmanaged approach and SubmitOrder would be best suited for this type of logic.


    Additionally, it sounds if the position may not be read correctly at the time you are checking it, this can be caused if you are submitting multiple order actions in the same OnBarUpdate.

    For example if you are currently 1 long and submit a Exit for the long order and also submit a EnterShort, the exit would make you flat but because OnBarUpdate has not been called again, the EnterShort would exit and enter making you 2 short instead of 1.

    At least one call to OnBarUpdate is required between order methods to Update the position.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply!

      Yes, it is a bracket order entry with a profit target and stop. It's probably an issue relating to what you're saying based on my code, because the MarketPosition shows a value of Short on a Strategy that has no EnterShort methods, so it must just be the system thinking I'm short because of an ExitLong and SetStopLoss.

      Thanks again

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Irukandji, Today, 04:58 AM
      0 responses
      2 views
      0 likes
      Last Post Irukandji  
      Started by fitspressoburnfat, Today, 04:25 AM
      0 responses
      2 views
      0 likes
      Last Post fitspressoburnfat  
      Started by Skifree, Today, 03:41 AM
      1 response
      4 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by usazencort, Today, 01:16 AM
      0 responses
      1 view
      0 likes
      Last Post usazencort  
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      604 views
      0 likes
      Last Post NinjaTrader_Jason  
      Working...
      X