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 CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    61 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    34 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    198 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    364 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    283 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X