Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Initialize Event triggered multiple times

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

    Initialize Event triggered multiple times

    I am new to NT and working on my first indicator. The description of Initialize indicates that it is triggered once, yet it appears to be triggered multiple times. First, when the Indicator icon at the top of a chart is clicked to bring up the Indicator dialog box. Then it is triggered again when my indicator is clicked in the list. It is triggered again when OK is clicked. Given the description, and the general rule in other environments that an Initialize event happens only once in the life of some object, I am surprised to see multiple triggers (demonstrated by printing a message to the output window from inside the Initialize method).
    Am I missing something, or is this behavior to be expected in a real Indicator?
    Thanks,
    Jack

    #2
    hello,
    These additional triggers of the Intialize() method you are seeing are expected. Although this method is called once on the start of an indicator or strategy, there are times that this method is also called (Opening an indicator dialog) when you may not expect it to.

    If we can be of any other assistance please let us know.
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the confirmation of behavior. But doesn't that suggest that the documentation should be revised? To me, executed once means in fact once. In the process control world that I come from, it is generally not a good idea to initialize something multiple times. And I think that is the case here also. Is there any way, short of some system of internal flags, to determine what action is triggering the Initialize event?
      Jack

      Comment


        #4
        Hello,
        This is outlined in the documentation.
        Please see the following link on the Intialize() method: http://ninjatrader.com/support/helpG...initialize.htm

        This is documented in the 3rd bullet point: "Although this method is called once on the start of an indicator or strategy, there are times that this method is also called (Opening an indicator dialog) when you may not expect it to. FOR ADVANCED PROGRAMMERS, DO NOT USE THIS METHOD TO RUN CUSTOM ROUTINES SUCH AS OPENING FORMS, MAKING EXTERNAL CALLS SUCH AS A LICENSE CHECK. PLEASE USE OnStartUp() FOR THOSE PURPOSES."

        The reason why you see it called here is that the indicators and strategies need to be initialized to generate the lists. If you have code that you have entered in the Initialize() method that you only want to be ran once you could use OnStartUp() instead. PLease see the following link on the OnStartUp() method: http://ninjatrader.com/support/helpG.../onstartup.htm

        There is not a way other than using Print() to check when the Initialize() method is called.
        Cody B.NinjaTrader Customer Service

        Comment


          #5
          Thanks for following up. After my second post I did eventually find the extended description of the Initialize event.
          Now what I would like to find is some overall description of the Object model in NT 7 (there appears to be better documentation for NT8 and I will likely move to that, but I would still like to understand NT 7). Specifically, if I have a chart with 2 instruments (2-minute bars plotted in 2 panels) I would expect something like a Chart object that contains a list of the Panels (for example). I have found no overview of the hierarchy of objects (and their methods) associated with a chart. And it is tedious, at best, to try to decipher what is happening using Intellisense. Basically I want to be able to query the container the indicator is in to decide what to do.
          Thanks.

          Comment


            #6
            Originally posted by TurtleBeach View Post
            Thanks for following up. After my second post I did eventually find the extended description of the Initialize event.
            Now what I would like to find is some overall description of the Object model in NT 7 (there appears to be better documentation for NT8 and I will likely move to that, but I would still like to understand NT 7). Specifically, if I have a chart with 2 instruments (2-minute bars plotted in 2 panels) I would expect something like a Chart object that contains a list of the Panels (for example). I have found no overview of the hierarchy of objects (and their methods) associated with a chart. And it is tedious, at best, to try to decipher what is happening using Intellisense. Basically I want to be able to query the container the indicator is in to decide what to do.
            Thanks.
            If you really want that kind of information, you will have to look to NT8. There is a simple reason. As NT themselves confess, they did not realize how important they were about to become to serious developers, and they leave unsaid that, for pre-NT8, it probably guided their focus towards users who might occasionally casually program, rather than towards developers who might be trading (or not, but still serious developers).

            They pretty much all but confess such in the guide to NT8, which is very much focused at developers and our need to know the internals of the API. Read this:

            We have enjoyed incredible success with our pioneering strategy of offering a standards based (.NET) programming environment for indicators and strategies. The types of add-ons created by our vibrant developer community wildly surpassed our expectations and prompted us to re-think how the NinjaTrader platform could evolve. With NinjaTrader 8 we have created a true trading application development platform, allowing developers to build incredibly rich and integrated applications limited only by the imagination. We are confident that by providing formal support for deeper access into our core framework we will energize the community to build even better tools, adding significant value to our ecosystem (www.ninjatraderecosystem.com).
            Emphasis mine.

            ref: http://ninjatrader.com/support/helpG.../whats_new.htm
            Last edited by koganam; 12-22-2015, 09:10 AM.

            Comment


              #7
              Hello,

              What you are looking for is not docuemented and is unsupported in NinjaTrader 7. This was not meant to be called or used on a user level. You could still use it if you like. I can not provide much information on this but as a hint you could use the ChartControl to get these values. You may be able to find more information on this by searching on the forum. This post may get you going a step in the right direction as well. http://ninjatrader.com/support/forum...51&postcount=4

              This is supported with NInjaTrader 8 though and documented. Please see the following link on the ChartControl documentation for NinjaTrader 8: http://ninjatrader.com/support/helpG...artcontrol.htm

              If we can be of any other assistance please let us know.
              Cody B.NinjaTrader Customer Service

              Comment


                #8
                Your response and Koganam's have convinced me to move to NT8, beta notwithstanding.
                Thanks.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                585 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                340 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                103 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                554 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                552 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X