Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancel Order in managed approach

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

    Cancel Order in managed approach

    Hello

    I have an strategy calculate OnBarClose and order entries with bool isLiveUntilCancelled true.

    I have these lines in OnBarUpdateSection to cancel them if prices goes up or go down a distance before execution (variables myEntryShortCancelPrice and myEntryLongCancelPrice.

    if (entryShortOrder != null
    && (Low[0] < myEntryShortCancelPrice))
    {
    CancelOrder(entryShortOrder);
    }

    if (entryLongOrder != null
    && (High[0] < myEntryLongCancelPrice))
    {
    CancelOrder(entryShortOrder);
    }

    There are lot of entries that are ordered and cancelled in the same moment. I guess the reason is that Highs or Lows of entry conditions bars are above or below my variables level to cancel, but that is previous than my order...

    Have you got any idea or example to solve that issue? Maybe adding something to "entryLongOrder != null" or "entryShortOrder != null"?

    Thanks in advanced

    #2
    Hello Impeesa,

    Thank you for the post.

    You mentioned that this may be because of the order previous to the current, are you setting the order variables to null when you cancel or see the order filled?

    For the condition you are using to work it would need to have entryLongOrder null to avoid canceling the order. If that was not null from a previous order then it could be true right away. This condition could still become true basically right away if the cancel price is less than the current high right after the entryLongOrder is assigned to the order. This depends on how frequent this logic is called from OnBarUpdate as well.

    If you are trying to avoid cancelling an order on the same bar you could add other logic like checking the BarsSinceEntryExecution or adding a variable to store the CurrentBar for comparisons.





    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

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