Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What is a good time frame for backtesting your strategy

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

    What is a good time frame for backtesting your strategy

    Hi Everyone,

    May be this has been answered already. I did a quick search and didn't see anything come up at least in the first few pages. I was wondering for an intraday strategy that produces on an average between 1-3 trades a day what's a good time frame for back testing the strategy?

    In Strategy Analyzer I can select the instrument say ES 12-22 and can backtest is going back many years but I don't know if that makes any sense or valid as the futures contracts are qtrly. I have been trading mainly manually up until now and looking at some strategies to automated and wanted to check with the pros here.

    Please let me know when you can. Any pointers on this would be much appreciated. Thanks in advance

    #2
    Hello vpatanka,

    You can use any time you would like to test the strategy, that is up to you and your goals. The platform can merge future contract data so you can select a long timespan if you would like to.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello vpatanka,

      You can use any time you would like to test the strategy, that is up to you and your goals. The platform can merge future contract data so you can select a long timespan if you would like to.
      "The platform can merge future contract data so you can select a long timespan if you would like to" answered my question. Thanks Jesse

      Comment


        #4
        Originally posted by vpatanka View Post

        "The platform can merge future contract data so you can select a long timespan if you would like to" answered my question. Thanks Jesse
        Hi Jesse,

        Is there a way to use "OnAccountItemUpdate" with strategy analyzer if I want to run my strategy to backtest much longer duration?

        I am using the code below
        protected override void OnAccountItemUpdate(Cbi.Account account, Cbi.AccountItem accountItem, double value)
        {
        // Updated Account P&L
        AccountRealizedPL = account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar);
        AccountUnrealizedPL = account.Get(AccountItem.UnrealizedProfitLoss, Currency.UsDollar);
        }​

        if (TotalPL >= <amount of profit per day>)
        CloseStrategy("MaxProfitClose");​

        which I can see working in "Replay" mode but when I backtest my strategy but not in Strategy Analyzer with much longer duration backtets. Is there a way to do that?

        Thanks in advance

        Comment


          #5
          Hello vpatanka,

          That would not be the correct way for a strategy to observe its PnL data, strategies are virtualized so using the account values directly would not be suggested. You can see the following sample which works in backtesting to reset daily and has a max profit/loss.



          Using CloseStrategy also would not be suggested in a backtest/playback, this terminates the strategy and disabled it from working further. If you wanted to test multiple days you can use the same type of logic shown in the above sample. That simply prevents the strategy from doing anything logically but keeps it running so it can reset for other days.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Jesse View Post
            Hello vpatanka,

            That would not be the correct way for a strategy to observe its PnL data, strategies are virtualized so using the account values directly would not be suggested. You can see the following sample which works in backtesting to reset daily and has a max profit/loss.



            Using CloseStrategy also would not be suggested in a backtest/playback, this terminates the strategy and disabled it from working further. If you wanted to test multiple days you can use the same type of logic shown in the above sample. That simply prevents the strategy from doing anything logically but keeps it running so it can reset for other days.
            I tried it and that works. Thanks.
            Is there a way to backtest a portfolio? I am running 10 different instruments with different timeframes and I wanted to see and say I have a daily profit target of 1k across the portfolio and if achieved it'll close all strategies and be done for the day. Is there a way do that at the portfolio level? Thanks in advance

            Comment


              #7
              Hello vpatanka,

              Yes that is called a basket test: https://ninjatrader.com/support/help...asket_test.htm

              You won't be able to test a daily profit target in a basket test across all instruments. Strategies are run individually and don't communicate with each other. To do a daily target for all instruments would require using a multi instrument strategy. You can see an example of a multi insturment strategy which comes with the platform, its called SampleMultiInstrument.

              You can read more on this topic here: https://ninjatrader.com/support/help...lightsub=multi
              JesseNinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Jesse View Post
                Hello vpatanka,

                Yes that is called a basket test: https://ninjatrader.com/support/help...asket_test.htm

                You won't be able to test a daily profit target in a basket test across all instruments. Strategies are run individually and don't communicate with each other. To do a daily target for all instruments would require using a multi instrument strategy. You can see an example of a multi insturment strategy which comes with the platform, its called SampleMultiInstrument.

                You can read more on this topic here: https://ninjatrader.com/support/help...lightsub=multi
                Thanks Jesse. I just looked at SampleMultiInstrument and looks like its the same strategy with same parameters but I can run it against multiple instruments with different timeframes which is good to know but in my case I have different strategies (each one has its own set of parameters) for different instruments in a basket. Is there a way to backtest that basket

                e.g.
                Strategy ATMLiveTradingCL10Min has variables ThresholdForEntry as 2 and EmaGap as 0.75
                where as
                strategy ATMLiveTradingES4Min has variables thresholdForEntry as 13 with the same EmaGap

                Would it be possible to backtest these two in the strategy analyzer? I have 8 others on 8 different instruments but once I know how to backtest it for 2 I can do the same for others included in the basket. Thanks

                Comment


                  #9
                  Hello vpatanka,

                  No you can only backtest 1 strategy at a time so you would need to combine those multiple strategies into one which can handle that amount of instruments and parameters for its logic.

                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Jesse View Post
                    Hello vpatanka,

                    No you can only backtest 1 strategy at a time so you would need to combine those multiple strategies into one which can handle that amount of instruments and parameters for its logic.
                    Got it. Thanks. I will look into that.
                    One last question - I have some skills with programming a strategy which I have done currently but combining my 10 strategies on 10 different instruments (some of them use different timeframes) into one that I can backtest might be out my capabilities.
                    Does NT recommend any third party company(ies) that I can get in touch with who can help with this? I am ready to pay a reasonable fee for the project. Please let me know. Thanks

                    Comment


                      #11
                      Hello vpatanka,

                      Out support cannot make recommendations but you can reach out to [email protected] to get infomration on third party developers.

                      JesseNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Gerik, Today, 09:40 AM
                      1 response
                      6 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by RookieTrader, Today, 09:37 AM
                      1 response
                      10 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by alifarahani, Today, 09:40 AM
                      0 responses
                      5 views
                      0 likes
                      Last Post alifarahani  
                      Started by KennyK, 05-29-2017, 02:02 AM
                      3 responses
                      1,284 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      Started by AttiM, 02-14-2024, 05:20 PM
                      11 responses
                      186 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Working...
                      X