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

Using historical data in live strategy

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

    Using historical data in live strategy

    I am writing a script to automate my strategy, in the script I need to refer to historical data ( 1 or 2 months back). when I started backtesting the strategy, I want to test for example for 2 days, the script doesn't load the historical data. so as soon as the script refers to historical data by bar index number it gives error and stops.

    what I need to write so that the script can access the historical data?
    any help please
    thanks

    #2
    Originally posted by alomaria View Post
    I am writing a script to automate my strategy, in the script I need to refer to historical data ( 1 or 2 months back). when I started backtesting the strategy, I want to test for example for 2 days, the script doesn't load the historical data. so as soon as the script refers to historical data by bar index number it gives error and stops.

    what I need to write so that the script can access the historical data?
    any help please
    thanks
    You cannot refer to data that you have not loaded. That is a logic issue, not a NT issue. If you need to refer to data, load the data, and gate the processing by using a time filter to ensure that you only start processing from however many days that you want to process.

    Comment


      #3
      Koganam, thanks for your answer, However, I have already the data loaded in NT database ( 4years data), I managed to do the backtesting using time filter in the script, but when I run the back test instead of putting 2 days period I put the start date as 2 months before the start date I want to test, so that the script read all the bars of 2 months to process and then process my 2 days test period. I am worry how I will handle this issue when I put the strategy live, I will not wait for 2 months in real time!! can you or any one help?? thanks

      Comment


        #4
        Originally posted by alomaria View Post
        Koganam, thanks for your answer, However, I have already the data loaded in NT database ( 4years data), I managed to do the backtesting using time filter in the script, but when I run the back test instead of putting 2 days period I put the start date as 2 months before the start date I want to test, so that the script read all the bars of 2 months to process and then process my 2 days test period. I am worry how I will handle this issue when I put the strategy live, I will not wait for 2 months in real time!! can you or any one help?? thanks
        I do not see why that is an issue. if you need to refer to data from 2 months ago, there is no alternative but to load that data. If your processing is gated to process only the previous 2 days, then you are at the last bar on the chart, so you will process only the last 2 days. What is the waiting for 2 months that you are talking about? When the strategy is live, it will read what data it needs and process that data however you say.

        Comment


          #5
          alomaria, welcome to our forums - what error message are you exactly getting please in the process?
          BertrandNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GussJ, 03-04-2020, 03:11 PM
          11 responses
          3,228 views
          0 likes
          Last Post xiinteractive  
          Started by andrewtrades, Today, 04:57 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by chbruno, Today, 04:10 PM
          0 responses
          7 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          440 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          12 views
          0 likes
          Last Post FAQtrader  
          Working...
          X