Announcement

Collapse
No announcement yet.

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.

    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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      661 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      375 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      110 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      580 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X