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

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.
    Kate W.NinjaTrader Customer Service

    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.
        Kate W.NinjaTrader Customer Service

        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
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by alifarahani, Today, 09:40 AM
            6 responses
            31 views
            0 likes
            Last Post alifarahani  
            Started by Waxavi, Today, 02:10 AM
            1 response
            17 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by Kaledus, Today, 01:29 PM
            5 responses
            13 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by Waxavi, Today, 02:00 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by gentlebenthebear, Today, 01:30 AM
            3 responses
            17 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X