Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator properties not updated in strategy

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

    Indicator properties not updated in strategy

    I've modified an indicator to keep track of different historical values and made them available as properties. I've tested the indicator directly on charts and it works as expected.

    However if I try to reference the indicator in a strategy none of the new properties are updated. I do not want to add the indicator with the Add() method to the chart. I've tried defining the indicator as a variable and instantiating it in the strategy every way I could think of but the indicator never calls it's OnBarUpdate method. And if I reference it directly by Indicator(parameters)[barsAgo] it only returns the underlying double defined in the original indicator. None of my new properties are accessible.

    The only way I have been able to get the indicator to work in a strategy as expected is to create a public method in the indicator called ForceUpdate() that manually calls it's OnBarUpdate. If I call ForceUpdate in the Strategy's OnBarUpdate method with the correct BarsInProgress I can get it to update correctly.

    There must be a better way to get this to work. I am not doing anything that unusual.

    Any help would be appreciated.

    #2
    Hello DeepCSystems,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    So we may investigate this matter further please answer the following questions.
    Is this indicator in NinjaTrader 7 or 8?
    How are you defining these variables you wish to access?

    I believe you may be looking to define the variables you wish to access in a Data Series instead of just a double for example. If you want to just have a double update you can take a look at the reference sample at the following link: http://ninjatrader.com/support/forum...ead.php?t=4991

    For information on Update from the reference sample above please visit the following link: http://ninjatrader.com/support/helpG...nt7/update.htm

    For information on Data Series please visit the following link: http://ninjatrader.com/support/helpG...ries_class.htm

    Comment


      #3
      Originally posted by DeepCSystems View Post
      I've modified an indicator to keep track of different historical values and made them available as properties. I've tested the indicator directly on charts and it works as expected.

      However if I try to reference the indicator in a strategy none of the new properties are updated. I do not want to add the indicator with the Add() method to the chart. I've tried defining the indicator as a variable and instantiating it in the strategy every way I could think of but the indicator never calls it's OnBarUpdate method. And if I reference it directly by Indicator(parameters)[barsAgo] it only returns the underlying double defined in the original indicator. None of my new properties are accessible.

      The only way I have been able to get the indicator to work in a strategy as expected is to create a public method in the indicator called ForceUpdate() that manually calls it's OnBarUpdate. If I call ForceUpdate in the Strategy's OnBarUpdate method with the correct BarsInProgress I can get it to update correctly.

      There must be a better way to get this to work. I am not doing anything that unusual.

      Any help would be appreciated.
      You need to call Update() in the getter for any properties that are not Plots. The method does exactly the same thing as your ForceUpdate() method.

      Indeed, the NT Help states it in pretty much those exact terms.

      ref: http://ninjatrader.com/support/helpG...nt7/update.htm
      Last edited by koganam; 04-22-2016, 07:32 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X