• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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, 02: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.
      JimNinjaTrader Customer Service

      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, 09: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.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ubainaqima, Today, 03:16 AM
            0 responses
            5 views
            0 likes
            Last Post ubainaqima  
            Started by Martin89, Today, 02:09 AM
            0 responses
            4 views
            0 likes
            Last Post Martin89  
            Started by reveleriez, Today, 01:14 AM
            0 responses
            8 views
            0 likes
            Last Post reveleriez  
            Started by Trade95, Yesterday, 05:38 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_EricB  
            Started by Karelgp7, Yesterday, 03:16 PM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X