Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to restart processing bars from the beginning

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

    How to restart processing bars from the beginning

    Hi,

    My indicator requires preprocessing, following which it has to start processing bars from the beginning. Is there a way to restart?

    Thank you

    #2
    Hello AiTrading,

    Thanks for your post.

    All the processing on historical bars should be done during the historical run when applying the indicator.

    That said, if you need to iterate through all the historical bars again, you could use a For loop that loops from 0 to the CurrentBar-1.

    CurrentBar: https://ninjatrader.com/support/help...currentbar.htm

    Let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon,

      Thank you for the suggestion.

      Since preprocessing involves calling other indicators that depend on the environment of the OnBarUpdate() and the following processing in turn depending on this environment, a simple loop may not work.

      As is I will have to popup a message to require users to restart the indicator by toggling some parameter. But it should be a simple matter to force a restart in code.

      Thanks.

      Comment


        #4
        Hello AiTrading,

        Thanks for your note.

        There are no documented or supported methods for reloading a NinjaScript programmatically similar to if you were to click the 'Reload NinjaScript' option in a chart's right-click menu.

        That said, this thread will be open for other community members to share their insights about an undocumented approach to accomplish this.

        Let us know if we may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Hi Brandon,

          Please suggest how to loop through Input in State.Historical to call an indicator for each bar.

          Thank you

          Comment


            #6
            Hello AiTrading,

            Thanks for your note.

            As previously stated, to loop through the historical bars on a chart, you would need to create a FOR loop that loops from 0 to CurrentBar-1. This would loop through all the bars from the first bar on the chart to the bar prior to the currently forming bar (CurrentBar).

            For information about creating FOR loops in C#, see this publicly available documentation: https://docs.microsoft.com/en-us/dot...ion-statements

            Let us know if we may assist further.
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment


              #7
              Hi Brandon,

              For example, how to provide input series for EMA(ISeries<double> input, int period) in a loop that iterates through INPUT values? Specifically, Series does not support an add method to create such an input.

              Thanks.

              Comment


                #8
                Hello AiTrading,

                Thanks for your note.

                Re-processing bars is not something that is supported. It is expected that you process the bars as the data comes in. It would not be possible to make the script re-process/recalculate in the same way it did the first time.

                That said, could you please clarify exactly what your overall goal is so we may provide some direction?

                I look forward to assisting further.
                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                Comment


                  #9
                  My indicator requires preprocessing, following which it has to start processing bars from the beginning. My question was - how to restart processing bars from the beginning? Your suggestion was iterate through all the historical bars instead of a reset. But for that I need to recreate an input series. Since none of it is supported, I assume I have to derive my own Series that with an Add method... unless you already have such a class.

                  Regards

                  Comment


                    #10
                    Hello AiTrading,

                    Thanks for your note.

                    There is not really any concept of pre-processing in the NinjaTrader platform. You start at bar 0 and move forward in time until you are in realtime where new bars continue to repeat the same process into the future so it can continue to calculate ongoing.

                    "My indicator requires preprocessing, following which it has to start processing bars from the beginning."

                    This is how all scripts work, it is not called pre-processing. It would be what I explained above.

                    You could go from bar 0 to CurrentBar for every bar to reprocess the data but that would likely be very expensive on resources to process with any large amount of data.

                    Let us know if we may assist further.
                    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                    Comment

                    Latest Posts

                    Collapse

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