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 KirkHammett, Today, 03:23 AM
      0 responses
      2 views
      0 likes
      Last Post KirkHammett  
      Started by eleven, Yesterday, 10:06 PM
      0 responses
      35 views
      0 likes
      Last Post eleven
      by eleven
       
      Started by ezrollin, Yesterday, 08:12 PM
      7 responses
      72 views
      0 likes
      Last Post bltdavid  
      Started by kyamato, 11-23-2021, 10:51 PM
      6 responses
      91 views
      0 likes
      Last Post jeronymite  
      Started by fscabrera03, Yesterday, 07:14 PM
      0 responses
      49 views
      0 likes
      Last Post fscabrera03  
      Working...
      X