Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy disabled detection

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

    Strategy disabled detection

    How can I detect if my strategy has been disabled?

    #2
    Hello johnman,

    Thank you for your post.

    You could monitor for State == State.Terminated in OnStateChange and then perform any cleanup actions - what are you needing to accomplish on termination of the strategy?

    Thanks in advance; I look forward to assisting you further.

    Comment


      #3
      A scenario is if I am not at my desk while the strategy is running, Get a notification that the strategy has been terminated could be useful.

      Comment


        #4
        Hello johnman,

        Thank you for your reply.

        You wouldn't be able to use Share() while the strategy is in anything other than State.Realtime unfortunately, which is what you'd need to send a text or email. Theoretically, you could use a public static variable that gets updated when the state is Terminated, however. I will work up an example and get that posted for you.

        Thanks in advance; I look forward to assisting you further.

        Comment


          #5
          Many thanks, I look forward to it.

          Comment


            #6
            Hello johnman,

            Thank you for your patience.

            I'm attaching a file you can import that contains three demonstration scripts. First, there is an addon script in which we create a static bool variable. There is also an indicator that would need to be applied to the chart (StrategyTerminatedAlert), then the actual Strategy itself (ExampleOnTerminatedStrategy). You'll want to open up the indicator and replace my test email address with your actual email, and you would need to set up the email in Tools > Options > General > Share Services if you've not already set that up. Obviously you could replace the method of alert with another alert method of your preference, but for simplicity's sake I chose email for this example.

            Once you've imported the attached file and set up the email, you'll want to apply the indicator to the chart first, then the strategy. You can test if the email is working by toggling the strategy on and off from the Strategies tab of the control center - you should get an email each time the strategy is toggled if you've set up the email correctly.

            Here's a link to our forums that goes over the necessary setup needed for email:
            Below is a list of known e-mail settings and information demonstrating configuring e-mail alerts within NinjaTrader. Included are settings which have been tested with basic accounts. Please ensure that your settings are configured identically to those included, as some only use the beginning of the e-mail address and do not


            Please let us know if we may be of further assistance to you.
            Attached Files

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            80 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            40 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            64 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            66 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            54 views
            0 likes
            Last Post CarlTrading  
            Working...
            X