Announcement

Collapse
No announcement yet.

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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            90 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            137 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            68 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            120 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            71 views
            0 likes
            Last Post PaulMohn  
            Working...
            X