Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How many times are indicators loaded?

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

    How many times are indicators loaded?

    I have an indicator that loads a large amount of data into memory. So I figured I would place this load in Indicator.Initialize. But it looks like this gets called quite a bit of times. I placed a simple:

    MessageBox.Show( "Count: " + count);

    Inside of Initialize. I put a count there just so I could make sure that Initialize was not being called multiple times. Which it was not. Rather, each was a new instantiation. And given I am loading quite a bit of data, this does not work. I find that it got called at each of the following points:

    1. When I had a chart up and clicked the "Add Indicator" button
    2. A 2nd time when I actually clicked on my indicator(on the list with the others)
    3. A 3rd and 4th time when I click apply to add my indicator to the chart

    Everything else works fine, but the indicator gets instantiated a total of four times. Which ends up chewing up a bunch of memory.

    Do you have any sort of "true" Initialize that only gets called when an indicator class is really actually going to be used? Or do I need to sort of simulate my own by using a temp variable and detecting the first time that OnBarUpdate is called. Then if so, when is Initialize actually supposed to use, given that NT seems to be creating quite a few temporary objects before it actually uses my indicator.

    Also, is any sort of method called when an indicator is "closed", like when the chart it is attached to is closing? So I can unload things?

    #2
    jeff,

    When you use apply it will reset the indicator and call the initialize method. The initialize method is called each time the indicator is instantiated.

    I will attempt to replicate and discuss with our tech leader to see if I can explain further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Jeff, can you try your loading in NT7's OnStartUp() instead?

      http://www.ninjatrader.com/support/h.../onstartup.htm

      To clean up custom resources used, you can use OnTermination().

      http://www.ninjatrader.com/support/h...ermination.htm
      BertrandNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by mg.watts, Today, 03:17 PM
      0 responses
      8 views
      0 likes
      Last Post mg.watts  
      Started by JTizz, Today, 01:20 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by omermirza, Today, 12:39 PM
      2 responses
      12 views
      0 likes
      Last Post omermirza  
      Started by mballagan, Today, 01:02 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Kate  
      Started by larkmail, Today, 12:30 PM
      3 responses
      11 views
      0 likes
      Last Post NinjaTrader_Kate  
      Working...
      X