Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

state confirmation

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

    state confirmation

    Hello, can you confirm what states an indicator goes through when changing a parameter and hitting APPLY then OK?

    I have some items - context menu related in own custom tool that are not being reset or cleared and are duplicating
    So it would seem i need to check and perform some housekeeping as it shifts through the state transitions when opening up indicator window and changing parameters then APPLY OK
    thanks

    #2
    Hello explorer101,
    Thanks for your post.

    You could expect State.SetDefaults or State.Configure in your scenario. You can verify what state the script is in by printing the State in your code and observing the NS Output window:
    Code:
    Print(State.ToString());
    You can also read more about the OnStateChange() method and what the different states are used for at the following help guide link:
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      thanks josh i have that print in already and ran through again in debug

      it seems the terminate is being called then the Historical processing - then terminate again

      when i APPLY and OK - it seems the context menu opening and closing i have is not functioning correctly

      This works fine before opening indicator window and then APPLY OK - but in following the sequence and checking objects
      something is not right.

      This is from a ninja sample :
      else if (State == State.Historical)
      {

      if (ChartControl == null) return;
      ChartControl.Dispatcher.InvokeAsync(new Action(() =>
      {
      ChartControl.ContextMenuOpening += ChartControl_ContextMenuOpening;
      ChartControl.ContextMenuClosing += ChartControl_ContextMenuClosing;
      mySmaMenuItem = new MenuItem { Header = "Test SMA Item" };
      myEmaMenuItem = new MenuItem { Header = "Test EMA Item" };
      mySmaMenuItem.Click += MySmaMenuItemClick;
      myEmaMenuItem.Click += MyEmaMenuItem_Click;
      }));
      }
      else if (State == State.Terminated)
      {
      if (ChartControl == null) return;
      if (mySmaMenuItem != null)
      {
      mySmaMenuItem.Click -= MySmaMenuItemClick;
      }
      if (myEmaMenuItem != null)
      {
      myEmaMenuItem.Click -= MyEmaMenuItem_Click;
      }

      ChartControl.ContextMenuOpening -= ChartControl_ContextMenuOpening;
      ChartControl.ContextMenuClosing -= ChartControl_ContextMenuOpening;


      }

      So i am essentially doing the same
      but why is terminate being called again after Historical when i do APPLY OK from the indicator panel

      thanks

      Comment


        #4
        explorer101,

        That sounds expected. As noted in the help guide, clicking APPLY OK and closing the Indicators window will trigger State.Terminated. But you should also be aware that the UI instances of the indicator will also trigger State.Terminated.

        When applying an indicator to your chart you would see Terminated>>SetDefaults>>Configure>>DataLoaded>>Hi storical>>Transition>>Realtime>>Terminated

        Please see the following help guide link regarding the "NinjaScript Lifecycle" for more information:




        Josh G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X