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

detect indicator removed or deactivated

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

    detect indicator removed or deactivated

    Hello,

    if I have installed an indicator (any),
    the following statuses are run through in the OnStateChange() method.

    OnStateChange() State: Terminated
    OnStateChange() State: Configure
    OnStateChange() State: DataLoaded
    OnStateChange() State: Historical
    OnStateChange() State: Transition
    OnStateChange() State: Realtime


    How can you tell if an indicator has been deactivated or removed from the chart?

    (I want to take certain actions when an indicator has been disabled or removed.)

    #2
    Hello 1001111,

    Thank you for the post.

    The State.Terminated would be how to tell that. Terminated can be called multiple times and for multiple different instances so depending on what you need to clean up you may need to also add logic to determine if the script actually started.

    Can you provide some detail about what you are trying to do when the script is disabled?

    A simple way to know the script started so you can know the next Terminated is actually when the script is being stopped would be to use a bool:




    Code:
    private bool myBool; 
    
    and then in OnStateChange: 
    
    if(State == State.Historical)
    {
        myBool = true; 
    } else if(State ==State.Terminated)
    {
        if(myBool == true)
        { 
             // we can safely assume the script was actually started because it hit state.historical
         }
    }

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post

      Can you provide some detail about what you are trying to do when the script is disabled?
      The indicator collects data during the term. But I have to delete it if it is deactivated or deleted.


      I'll try what you wrote. Thanks a lot

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by dcriador, Today, 12:06 PM
      0 responses
      6 views
      0 likes
      Last Post dcriador  
      Started by dcriador, Today, 12:04 PM
      0 responses
      5 views
      0 likes
      Last Post dcriador  
      Started by cutzpr, Today, 08:54 AM
      0 responses
      11 views
      0 likes
      Last Post cutzpr
      by cutzpr
       
      Started by benmarkal, Today, 08:44 AM
      0 responses
      17 views
      0 likes
      Last Post benmarkal  
      Started by Tin34, Today, 03:30 AM
      2 responses
      28 views
      0 likes
      Last Post Tin34
      by Tin34
       
      Working...
      X