Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Notification on StopCancelClose

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

    Notification on StopCancelClose

    Hello,
    I'd like to get notified say via:
    Code:
    SendMail()
    , when a running strategy is terminated for any reason, via the default:
    Code:
    RealtimeErrorHandling.StopCancelClose;
    Thanks for your help!

    #2
    Hello aaadetos,

    Thanks for your message.

    SendMail must be called from State.Realtime, so I may suggest the following:
    1. Set RealtimeErrorHandling to IgnoreAllErrors
    2. In OnOrderUpdate, check for orders that reach a state of OrderState.Terminated or if the order returns an error ErrorCode other than ErrorCode.NoError. (This will trap rejections and order errors so we can Stop the Strategy, Cancel Orders, and Close Positions as would be done with RealtimeErrorHandling.StopCancelClose.)
    3. When the order error or rejection is trapped, call SendMail(), and then call CloseStrategy()
    This will allow the strategy to call SendMail while still in State.Realtime, and then go back to the standard CloseStrategy behaviors.

    SendMail() - https://ninjatrader.com/support/help.../?sendmail.htm

    CloseStrategy() - https://ninjatrader.com/support/help...sestrategy.htm

    OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks Jim

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Segwin, 05-07-2018, 02:15 PM
      10 responses
      1,767 views
      0 likes
      Last Post Leafcutter  
      Started by Rapine Heihei, 04-23-2024, 07:51 PM
      2 responses
      30 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by Shansen, 08-30-2019, 10:18 PM
      24 responses
      943 views
      0 likes
      Last Post spwizard  
      Started by Max238, Today, 01:28 AM
      0 responses
      9 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by rocketman7, Today, 01:00 AM
      0 responses
      7 views
      0 likes
      Last Post rocketman7  
      Working...
      X