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

Are indicators instantiated 4 times?

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

    Are indicators instantiated 4 times?

    Hello there,
    I'm a NinjaScript newbie, so be comprehensive for the silly question.

    I created an indicator using NinjaScript with only the Name and the Description. Than I added a private static field as a counter of the number of instances that are created by NinjaTrader when you add it to a chart. I then defined a default contrustructor (i.e. with no parameters) for the indicator to increment the counter and print its value.

    It seems that during the life cycle of an indicator it get instantiated 4 times and destroyed 3 times.

    1. when first I open the dialog to add an indicator to the chart
    2. when I add the indicator to the chart
    3. when I apply the association (or click ok)
    4. Before the indicator get truly attached to the chart.

    At the end survives just the last instance of the indicator. Did I do something wrong or is the standard way NinjaTrader manages indicators?

    Best regards


    #2
    Hi magomimmo, thanks for posting.

    The indicator object is created in a factory by the NinjaTrader core, that is why the "new" keyword is not used when instantiating indicators. e.g. dynamic MySMA = SMA(14);

    The 4 instantiations are used to populate indicators in the property grid. The final instance is the one that will run on the chart which will be destroyed when the chart is closed or the platform shuts down.

    There is a full description of the lifecycle here:


    Best regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks so much NinjaTrader_ChrisL.

      My best

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      56 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      35 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      7 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      19 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      8 views
      0 likes
      Last Post cre8able  
      Working...
      X