Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Recalculate Historical Data

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

    Recalculate Historical Data

    I created a toolbar for my indicator that changes certain condition which need to recalculate historical data based on new condition. How can I rerun the calculation on historical data when it is already loaded?

    #2
    Hello Djspinburner,

    Any time historical data is loaded or reloaded, or anytime the script is added or refreshed, the script will automatically reprocess all historical data.

    If none of these actions has not happened then the historical has not changed.

    If you want to loop through the historical data anyway you can do with with a for loop.

    For example:
    for (int i = 0; i < CurrentBars - 1; i++)
    {
    Print(string.Format("{0} | BarsAgo: {1} | Close: {2}", Time[i], i, Close[i]));
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Your suggestion calculates the data backwards, I need it to calculate forward, however if I reverse your statement I get index out of range error. I need the data to calculate with the olders bars first to the newest bars last. In NT 7 i simply passed the SendKeys.Send("{F5}"); In NT8 that resets the toolbar back to defaults hence making it somewhat useless..

      Comment


        #4
        Hi Djspinburner,

        I only suggesting you use a loop. How you write is up to you.

        Start at CurrentBar minus 1 and decrement until no longer greater than 0 if you would like.

        The example just shows what a loop looks like. I'm not providing the exact code you should use in your script.

        Below is a link to a 3rd party educational site on using for loops.


        And always ensure if you are going to use an index that that index exists first.

        For example using a barsAgo value equal to or greater than the total number of bars would result in an index error.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

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