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

NinjaScript Indicator/Strategy Class Call Order

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

    NinjaScript Indicator/Strategy Class Call Order

    Hi,

    I’m hoping to break my indicators and strategies into components so I can easily re-use code & not have to make multiple changes to update similar logic, etc.

    My question is, in what order will my indicators and strategies receive OnBarUpdate() events? Is it deterministic or will it be random? I just want the assurance that within a single global OnBarUpdate event, one object will receive data, process/store it, then another object will be able to read that stored data (before the next OnBarUpdate). Another question, how does it affect this ordering when I go from OnBarClose to OnEachTick?

    #2
    Hello trevor14,

    This would be outside of what is supported by NinjaTrader, but the post below has some tips that may give you some ideas for an unsupported approach.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      NinjaScript isn't supported by NinjaTrader?

      Comment


        #4
        Hello trevor14,

        Documented NinjaScript that is in the help guide is supported by NinjaTrader.


        Breaking things into module classes using custom C# instead of making a straight forward indicator or strategy that does not have shared classes is not supported by NinjaTrader.

        This would be custom C# and would not be specifically NinjaScript.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          This is what I thought and tried buy while debugging the code I don't see it enters the OnBar Update of the indicator. Am I missing something?

          protected override void OnBarUpdate()
          {
          aoBalance.Update();
          for (int i=0; i< aoBalance.BalanceAreas.Count; i++)
          {
          BalanceArea ba = aoBalance.BalanceAreas[i];
          Draw.Rectangle(aoBalance, ba.Tag, ba.StartBar, ba.Min, 0, ba.Max, Brushes.Green);
          }
          }

          Comment


            #6
            Hello ofiramitai,

            Use prints to understand the behavior.

            Print aoBalance.BalanceAreas.Count and the time of the bar before the loop.
            Print i and aoBalance.BalanceAreas[i] inside the loop.
            Print ba.Tag, print ba.StartBar, print ba.Min, print ba.Max inside the loop after ba is declared and assigned.

            Below is a link to a forum post that demonstrates how to use prints to understand behavior.


            Save the output from the output window (right-click -> Save As) to a text file and include this with your reply.
            I am happy to assist with analyzing the output.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            44 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            20 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            179 views
            0 likes
            Last Post jeronymite  
            Started by ghoul, Today, 06:02 PM
            0 responses
            10 views
            0 likes
            Last Post ghoul
            by ghoul
             
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            13 views
            0 likes
            Last Post DanielSanMartin  
            Working...
            X