Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why Documentation, and neither NT ide mentioned the "State" -"Finalized" ?

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

    Why Documentation, and neither NT ide mentioned the "State" -"Finalized" ?

    I have accidentally cought the `State` value of "Finalized" (State==State.Finalize). I thought only these were available:

    Why neither IDE, nor the NT documentation mentions this VERY useful state (it's sometimes only available way for doing things, which cant be done with `Terminated` state)?
    Last edited by ttodua; 02-27-2019, 03:16 AM.

    #2
    Can anyone answer?

    Comment


      #3
      Hello TazoTodua,

      Thanks for your post.

      This state is not documented because it is not intended for regular use. Everything that you may wish to do in NinjaScript can be accomplished with an understanding of the NinjaScript Lifecycle and the documented states.

      NinjaScript LifeCycle - https://ninjatrader.com/support/help...fecycle_of.htm

      OnStateChange (Documented states) - https://ninjatrader.com/support/help...tatechange.htm

      Could you provide an example where you have to use State.Finalized where you cannot use State.Terminated?

      I look forward to being of further assistance.

      Comment


        #4
        NinjaTrader_Jim Yes, there are cases when FINALIZED makes the essential job, while others cant!

        1) please see my another topic: https://ninjatrader.com/support/foru...dispose-mehtod

        2) bind attaching i.e. mouse-click event to chart from EXTERNAL script (which has indicator's `this` instance passed to it), and then after removing the indicator from chart, that mouse-click event stays still on chart. Only state.Finalized is solution. Here example:


        Code:
        class MyClass
        {
            Indicator indi ;
        
            public MyClass(Indicator instance)
            {
                indi = instance;
                indi.ChartPanel.MouseDown += this.OnMouseDownEvent;
            }
        
            private void OnMouseDownEvent(object sender, MouseButtonEventArgs e)
            {
                if (indi.State != State.Finalized)
                    ... do desired  action
        
                else (indi.State != State.Finalized)
                     indi.ChartPanel.MouseDown -= this.OnMouseDownEvent;
        
            }
        }
        
        
        
        MyIndicator:
        
           OnStateChange->DataLoaded
           {
               new MyClass(this);
           }
        Here the only way is that? Otherwise you have to do hard-coding to remove that external programs from current idnicator's "terminated" state. However, the above solution makes very easy to create many plugabble scripts onto the chart (only 1 line is needed in indicator), like i shown. Making it very useful for external programming.

        3) and a surprise: a set of NT builting script also use this state (screenshot of TextCralwer, i like that app : https://i.imgur.com/pmi2oey.png
        Last edited by ttodua; 02-27-2019, 10:05 AM.

        Comment


          #5
          NinjaTrader_Jesse might step in here to share his thoughts.

          Comment


            #6
            Hello TazoTodua,

            Thanks for providing the example.

            NinjaTrader_Jesse had submitted a feature request in the thread where you were previously inquiring on State.Finalized to have this state documented. The ticket ID is SFT-3855.

            Hooking up your indicator to an external script to attach handlers would not be a supported use of the software that we would recommend. Instead, we would advise to add the handlers in the script itself and then to unsubscribe and dispose of resources when the script reaches State.Terminated. As with other undocumented/unsupported code, you are welcome to use it if you find an application, but we will not be able to provide any further direction for usage.

            Let us know if you have any additional questions.

            Comment


              #7
              I think it is still not Documented, correct? I don't find it in the documentation but it seems important to me.

              Comment


                #8
                Hello giogio1,

                That is correct, the feature request still exists but has not been implemented. For any NinjaScript use that is not intended to be used so is not documented, we would suggest using Terminated for your end of script life actions. If you have a valid reason why that wont work feel free to post a simple example and we can include that in the request.

                Comment


                  #9
                  I noticed it is called when the time interval changes, not sure what other purposes calls it, but it definitely caused me some heart burn, as I didn't expect a change of the time interval would call configure. In my case, it doesn't work to dispose on terminated, as that is called too frequently for the purposes of my indicator. In my case, I must keep it alive unless they actually remove the indicator, or modify the input parameters. There doesn't seem to be a great way to know if the indicator was removed or the parameters the user enters are updated.

                  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