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

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 judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        55 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Today, 06:52 PM
        4 responses
        35 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        19 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        7 views
        0 likes
        Last Post cre8able  
        Working...
        X