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

Who and when is OnBarUpdate called for child classes?

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

    Who and when is OnBarUpdate called for child classes?

    I apologize if the answer to this question exists in the documentation. I have spent much time browsing the forum, but could not find the answer to my particular question.

    I have the following situation:

    I have a main strategy class which is derived from Strategy. There is nothing unusual about this strategy. Assume that it is any basic strategy.

    This strategy has a collection of sub-strategies which derive from my custom interface IStrategy. These sub-strategies do NOT derive from NinjaTrader's Strategy. They contain custom code. I do pass the parent strategy to these sub-strategies, in their constructors. The idea is that on each call to OnBarUpdate() in the parent strategy, I loop through my sub-strategies to see if any of them trigger an entry signal.

    In the sub-strategies classes, I declare some indicators.

    Here is my question: How can I be sure that my sub-strategies' indicators are having their individual OnBarUpdate() methods called?

    I have learned from my research that there is some magic that happens when an indicator is declared in the main strategy class (that is derived from Strategy) so that the indicator's OnBarUpdate() method is automatically called. BUT... how may I make sure that my custom sub-strategies' indicators are also updated?

    Thanks!

    #2
    Hello rgoudie,

    Thanks for your post.

    Only Strategy, Indicator and in a more limited sense, MarketAnalyzerColumn, classes provide OnBarUpdate functionality and would support using indicators. Indicators would not be supported to be used in other classes. Similarly for AddOns where there is no OnBarUpdate, the indicator logic would need to be reimplemented in a BarsRequest to have that indicator logic present there.

    What you are attempting would be outside our scope of support, but you may want to try implementing a public method in your custom class that has the indicators call indi.Update(idx, bip); Where idx is the CurrenBar index from the main strategy, and bip is the BarsInProgress of the data series in the indicator you want to update. You may reference our Order Flow Cumulative Delta indicator documentation to see how Update is used there.

    Update - https://ninjatrader.com/support/help...tml?update.htm

    Order Flow Cumulative Delta - https://ninjatrader.com/support/help...ive_delta2.htm

    I cannot guarantee this will work since we are moving into unsupported areas involving using indicators outside of their intended classes, but if you have luck, it may be useful for the community to share what you have attempted and what has worked for you.

    JimNinjaTrader Customer Service

    Comment


      #3
      Jim, thank you very much for your reply. This does give me a good starting point. I will definitely share the results of any success that I have.

      Cheers!


      Originally posted by NinjaTrader_Jim View Post
      Hello rgoudie,
      Thanks for your post.

      Only Strategy, Indicator and in a more limited sense, MarketAnalyzerColumn, classes provide OnBarUpdate functionality and would support using indicators. Indicators would not be supported to be used in other classes. Similarly for AddOns where there is no OnBarUpdate, the indicator logic would need to be reimplemented in a BarsRequest to have that indicator logic present there.

      What you are attempting would be outside our scope of support, but you may want to try implementing a public method in your custom class that has the indicators call indi.Update(idx, bip); Where idx is the CurrenBar index from the main strategy, and bip is the BarsInProgress of the data series in the indicator you want to update. You may reference our Order Flow Cumulative Delta indicator documentation to see how Update is used there.

      Update - https://ninjatrader.com/support/help...tml?update.htm

      Order Flow Cumulative Delta - https://ninjatrader.com/support/help...ive_delta2.htm

      I cannot guarantee this will work since we are moving into unsupported areas involving using indicators outside of their intended classes, but if you have luck, it may be useful for the community to share what you have attempted and what has worked for you.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rajendrasubedi2023, Today, 09:50 AM
      2 responses
      13 views
      0 likes
      Last Post rajendrasubedi2023  
      Started by geddyisodin, Today, 05:20 AM
      4 responses
      28 views
      0 likes
      Last Post geddyisodin  
      Started by geotrades1, Today, 10:02 AM
      2 responses
      8 views
      0 likes
      Last Post geotrades1  
      Started by ender_wiggum, Today, 09:50 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by bmartz, Today, 09:30 AM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Erick  
      Working...
      X