Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using ExitLongLimit/Stop with onPriceChange

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

    Using ExitLongLimit/Stop with onPriceChange

    I created a strategy with strategy builder. I used ExitLongStop/Limit for my stop/TP because I wanted to be able to pass a variable into the stop loss.

    When I first ran the strategy, I found sometimes my exit orders were being cancelled before the stop or TP was hit, leaving my original long order running loose. The log said the orders had expired.

    I then edited my strategy to have the exitLong constantly repeat, only then did the trade play out as intended. However, I'm using on price change. So this means every price change my strategy is trying to resubmit the same exitLong orders over and over and over again. Obviously the orders get ignored as they already exist but Is this how it should be?

    #2
    Hello lucyb,

    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.

    When using the Strategy Builder, orders are submitted without using the isLiveUntilCancelled bool and will be false, meaning orders will be automatically cancelled.

    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 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


      #3
      Thank you. I guess I did it correctly.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      43 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      124 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      65 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