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 burtoninlondon, Today, 12:38 AM
          0 responses
          10 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          14 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          11 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Yesterday, 07:51 PM
          0 responses
          14 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,983 views
          3 likes
          Last Post jhudas88  
          Working...
          X