Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Capturing the rejection signal

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

    Capturing the rejection signal

    I would like to capture the order rejection signal before it shuts down my strategy. I would like to do that so that I can send an email/text to my phone so that if I'm not on my computer when it happens I can react accordingly. Is there a way to do the following:

    1. send a rejection signal (for testing purposes)
    2. redirect the rejection signal to a method
    3. send a text/email
    4. continue with the strategy termination (presumably with CloseStrategy())

    I have code in OnOrderUpdate to recognize the rejection like the following code snippet but it doesn't seem to work as I have not seen my Print statement in the output window. I am unsure if this will ever get triggered or will the strategy have already terminated before it gets there.

    if (error == ErrorCode.OrderRejected
    || error == ErrorCode.OrderRejectedByRisk)
    {
    string msg = string.Format("**** {0} Order Rejected: {1} with stop {2}",time, order.OrderType, order.StopPrice);
    Print(msg);
    // I would add MySendText(msg) here //
    CloseStrategy(terminateSignal);
    }

    ​I'm also presuming that CloseStrategy closes any existing trades and cancels any existing orders for that instrument. If incorrect, please let me know.

    #2
    Hello dweems,

    Thank you for your post.

    In order to send a text or email when an order is rejected, you will need to adjust the RealtimeErrorHandling for your strategy. The default behavior is StopCancelClose which will stop the strategy, cancel any remaining orders, and close any open positions. This means your snipped is likely not being reached because the strategy will stop before it can evaluate the logic when the order is rejected. You would need to code your own logic using StopCancelCloseIgnoreRejects or IgnoreAllErrors. For more information about RealtimeErrorHandling:


    To send a message programmatically, you could use SendMail() or Share():CloseStrategy() is described in detail on the following help guide page:


    The CloseStrategy() method cancels all working orders, closes open positions, and then disables the strategy.

    Please let us know if we may be of further assistance.

    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