The link to the Terminate discussion -- NinjaTrader_Matthew's detailed description appears correct overall but some details seem to have changed since then. In particular, the instance he describes for populating the "Configures:" list is created but immediately afterward another instance is also created and then terminated. I have no idea why this added instance; I also do not know any reason to care. It just adds to the main point -- that SetDefaults is called a lot and must be kept light.
-----
Explicit indicator constructor -- I know of no reason to have an explicit indicator constructor::
- NinjaTrader adds its own constructor and that is the one that is used to construct the instance.
- One job of a constructor is to call the base class constructor. In this case, the NT constructor does that so any attempt by an explicit indicator constructor to do so would be evil.
- The other important aspect of a constructor is to run first so it can initialize things. As demonstrated earlier in this thread, an explicit indicator constructor does not run first -- SetDefaults is called before that "constructor" is run.
- Any constructor shares one aspect with SetDefaults -- that both are run for every instance of the indicator. That means that both of them must be kept similarly light. In other words, lightness is just as important for a constructor as it is for SetDefaults.
-----
For an indicator, the very first call to its code will be OnStateChange() with State = SetDefaults. That call will happen exactly once. SetDefaults need not be concerned with being called again -- it never will be called again. All other code can assume that it has already been called.
- Is that really true?
- Can caching result in an instance being taken from the cache and having SetDefaults called another time?
-----
My thanks for the links to the indicator lifetime and state mechanism. That has never been an issue, though. The information I have asked about, and still do not know the answer to, is how, considering the several sources, an indicator's data gets initialized. When, from construction until the start of State=Configure does the data get changed? When is stored data read in and applied? Where do Clone() and ModifyProperties() fit into this scheme? Why does SetDefaults have to rely on dynamic setting of its own variables that could be initialized at compile time? Etc.
--EV

Comment