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 NullPointStrategies, 03-13-2026, 05:17 AM
            0 responses
            93 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            152 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            80 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            53 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            65 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X