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

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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            7 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            12 views
            0 likes
            Last Post Javierw.ok  
            Started by timmbbo, Today, 08:59 AM
            2 responses
            13 views
            0 likes
            Last Post bltdavid  
            Working...
            X