Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Accessing Historical Data from Live Strategy

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

    Accessing Historical Data from Live Strategy

    I have a strategy that needs to look at the prior n bars in order to calculate market conditions. Of course I can just wait for n bars to be processed in the strategy, but if n is large I'd like to pull that from historical data (rather than wait several hours/days each time the strategy is started in real time before trading).

    How do I go about doing this? Thanks

    #2
    You don't need to do anything special, other than making sure you have enough bars loaded in the chart you're running the strategy and in the strategy be sure to do a check of having enough bars (eg. something like CurrentBar > n where n is the number of bars you minimally need).

    HTH

    Comment


      #3
      Hello typedef struct,
      Welcome to the forum and I am happy to assist you.

      Say, you want to get the value of a bar 10 bars back, then you can call the bar using the below code
      Code:
      if (CurrentBar < 10) 
      {
         double close10back = Close[10];
      }
      JoydeepNinjaTrader Customer Service

      Comment


        #4
        Ok, great. I figured that when I started a strategy up, there would be no bars available until it had been running long enough to collect those bars. Good to know it can use historical bars automatically if they exist.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        65 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        149 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        99 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        286 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X