Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

market stop loss cancelled

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

    market stop loss cancelled

    Hi, after entering a buy limit order by: " entryOrder = EnterLongLimit(1, currentPrice , "limit_Long_Entry");",
    I issue an associated "sell stop market" order by: " ExitLongStopMarket(1, currentPrice - stopLossGAP*2 , "Market_Sell_Stop_Loss", "limit_Long_Entry");".
    However, this "sell stop market" order issued by "ExitLongStopMarket" is being almost immediately cancelled with no apperant reason.
    tracking the lifecycle of the order using Prints, together with a message printed in the event handler "OnOrderTrace" (marked below with *) result with the following text:

    2024-10-25 19:10 - Market_Sell_Stop_Loss state is: Submitted
    2024-10-25 19:10 - Market_Sell_Stop_Loss state is: Accepted
    2024-10-25 19:10 - Market_Sell_Stop_Loss state is: Working

    * Strategy 'MyCrossOverRunningAvg20241020/341392136': Cancelled expired order: BarsInProgress=0, orderId='NT-00022-144' account='DEMO3323639' name='Market_Sell_Stop_Loss' orderState=Working instrument='MES DEC24' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=5874.5 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-10-25 19:10:30' gtd='2099-12-01' statementDate='2024-10-26'

    2024-10-25 19:11 - Market_Sell_Stop_Loss state is: CancelPending
    2024-10-25 19:11 - Market_Sell_Stop_Loss state is: CancelSubmitted
    2024-10-25 19:11 - Market_Sell_Stop_Loss state is: Cancelled​

    Will appreciate ideas what might be the source of the order forced cancelling.
    Thanks
    Last edited by shil111; 10-26-2024, 04:11 AM.

    #2
    Update: it seems that isLiveUntilCancelled​ = true help with that, although some wierd stuff are still happening. we'll see..
    Does this mean a market/stop order lifespan, in the default setting, is for one candle only? This seems improbable... I assume I missed something here.
    Last edited by shil111; 10-26-2024, 06:29 AM.

    Comment


      #3
      Hello shil111,

      Thank you for your post.

      Orders submitted by a managed approach strategy are automatically cancelled when the submission bar closes if the order is not filled when isLiveUntilCancelled is false or the overload with the isLiveUntilCancelled parameter is not used.

      See isLiveUntilCancelled in the help guide.



      To keep limit and stop orders alive, continue re-submitting the order on each new bar for as long as you would like the order to remain alive. Save the limit or stop price to a double variable when the entry condition is true, and this can be used as the limit or stop price of the order on each resubmission.

      Below is a link to an example created with the Strategy Builder that demonstrates saving the order price to a variable and using bools to know when to keep an an exit order alive by resubmitting the order.



      The alternative is to unlock the script and code by hand. With this the method overload signature with the isLiveUntilCancelled parameter can be set to true and the order will not automatically be cancelled.

      EnterLongLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, string signalName)

      Below is a link to unlocked examples that demonstrate.



      Please let me know if this does not resolve your inquiry.

      Comment


        #4
        Thank you for the detailed response.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X