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

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.
        Iterate over numbers with for. Increment or decrement an index int from a start to an end value.


        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 briansaul, Today, 05:31 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by PaulMohn, Today, 03:49 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by frslvr, 04-11-2024, 07:26 AM
        6 responses
        106 views
        1 like
        Last Post NinjaTrader_BrandonH  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        6 responses
        26 views
        0 likes
        Last Post trilliantrader  
        Started by arvidvanstaey, Yesterday, 02:19 PM
        5 responses
        14 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Working...
        X