• 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

Instantiation of Indicators

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

    Instantiation of Indicators

    Can anyone tell me at what time(s) Indicators (and for that matter Strategies) are instantiated?
    I have been assuming that a new Indicator object is created each time an Indicator is actually applied to a Chart (or used in some other framework, but right now I am focusing on Charts).
    And a related question, are private variables instance variables or class variables (akin to static in Java). Again I have been assuming that private variables are instance variables.
    Behavior of event processing when the same indicator is applied to two instruments (each in a separate panel on a Chart) now leads me to think my assumptions were not correct.
    A clear statement of when Indicator objects are instantiated would save a lot of tedious time with the VisualStudio debugger.
    Thanks

    #2
    Hello TurtleBeach,

    Thank you for your inquiry.

    Indicators and strategies are instantiated upon opening the Indicator window for indicators and the Strategy window for strategies on a chart. To demonstrate this, you can place a Print() in the if (State == State.SetDefaults) statement inside of the OnStateChange() method of your script. You will then see your script print upon opening the Indicator/Strategy window.

    To learn more about when these various states occur, I would suggest taking a look at the NinjaTrader 8 help guide at this link: http://ninjatrader.com/support/helpG...tatechange.htm

    Private variables are instance variables. Class variables would not be private and would utilize the static modifier, i.e.:
    Code:
    static int theNumber = 42;
    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the information about Indicator instantiation.
      But your answer leads to further questions (as noted in the documentation, the SetDefaults **event** occurs multiple times so it is not actually an indication of object creation, other than that an object does exist).
      So to rephrase my original question, during a NinjaTrader Session (starting the Program, doing various things, ending the program) is there only ONE instantiation of each Indicator (or, if the Indicator dialog is never opened, Indicators are not instantiated)?

      As a suggestion to the NT developers, I would like to see an OnCreation event that truly occurs ONLY ONCE for any object that is created; similarly, an OnDeletion that occurs only when an object is about to be destroyed (since OnTermination is already taken and is not unique). These are really the two places initialization and other housekeeping can be safely done - especially since it appears I have to build in logic in every event to determine which chart/instrument the event applies to.
      Thanks.

      Comment


        #4
        Hello TurtleBeach,

        Thank you for your patience.

        Indicators can be instantiated multiple times. Two examples are by opening the indicators window and adding the indicator to the chart.

        State.SetDefaults is called once the object is created. This looks to occur multiple times as different instances of an indicator can be created more than once.

        Please, let us know if we may be of further assistance.
        Zachary G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Jschmelz, Yesterday, 04:45 PM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by sisenberg, Today, 07:29 AM
        1 response
        8 views
        0 likes
        Last Post sisenberg  
        Started by Oceans, Today, 02:22 AM
        2 responses
        25 views
        0 likes
        Last Post Oceans
        by Oceans
         
        Started by sisenberg, Yesterday, 08:06 PM
        1 response
        25 views
        0 likes
        Last Post sisenberg  
        Started by PLeary, Today, 06:25 AM
        1 response
        18 views
        0 likes
        Last Post NinjaTrader_SergeyS  
        Working...
        X