forex.pm forex forum binary options trade - Forex - How to Backtest Day Trading Strategies
  • Welcome to forex.pm forex forum binary options trade. Please login or sign up.
 

How to Backtest Day Trading Strategies

Started by PocketOption, Jan 31, 2023, 10:32 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PocketOption

How to Backtest Day Trading Strategies

Backtesting a day trading strategy is different than backtesting a swing trading strategy. This tutorial will help you understand the difference and give you the proven process for backtesting an intraday trading strategy.


To properly backtest a day trading strategy a trader must create a trading plan, choose the right software, monitor trading expenses, test the correct historical periods, and do a detailed analysis of the results.   


I'll also share with you how to figure out when it's time to start trading a strategy live, as well as the best tools and resources that you can use to start backtesting.


Now let's get into the details of each aspect of the process.




Create a Trading Plan


The first step in the process is to create a detailed trading plan.


A trading plan must consist of the following:



  • Entry criteria

  • Risk or lots per trade

  • Where to place your stop loss

  • When to exit the trade

  • How to trail your stop loss (if applicable)


You should write down your plan on a piece of paper or in a digital file like a Word Document.


Reference this trading plan every time you're about to enter a trade in backtesting.


It will help you remember the rules of a trading strategy and you'll be less likely to make a mistake.


If you want a downloadable trading plan worksheet, you can get it here.


How to Choose the Right Backtesting Software


The next step is to choose the software that you're going to use to backtest with.


There are many options out there, but the best option for you will depend on 3 primary factors.


Manual or Automated


Many new traders want to start off with automated backtesting so they can backtest a ton of data very quickly.


That's ideal…in theory.


In reality, most trading strategies cannot be 100% automated because there are certain criteria that rely on trader discretion and not on purely robotic steps.


On top of that, most people don't have the skills to start programing trading systems.


Therefore, it's generally best to start with manual backtesting.


If you really want to do some automated backtesting, find a backtesting platform that allows you to do partially automated backtesting and does not require coding.


That will allow you to get started quickly and you can step up to learning to code later.


What if you are already a programmer?


Then you're ahead of the game. Look into using languages like Python to automate your backtesting.


The Market You Trade


Some software programs are specifically built for certain markets. If you use them to backtest other markets, they might not work as well.


For example, Amibroker is great for backtesting automated stock trading strategies. But it's not good for backtesting in Forex.


Forex Tester works very well for backtesting Forex strategies, but it's not as good for testing strategies in futures trading.


So look for the best software for the market you're going to test.


Cost of Software and Data


The great thing about trading is that there are many tools available for big and small budgets.


If you want to keep your costs low, you can go with a free platform like MetaTrader 5. It usually provides a decent amount of historical data and the software is easy to use.


On the downside, these free programs are very bare bones and you won't get features like detailed reporting, which can save you a lot of time.


To get more time-saving features, you can use platforms like NakedMarkets or MultiCharts.


In my opinion, it's best to pay up for a professional quality software package. They save you a lot of time and time is the only thing you cannot get back.


Now let's talk about data…


Sometimes these backtesting platforms don't provide enough historical data. Luckily, you can download the data separately and upload it to your backtesting platform.


Amibroker allows you to download data from free websites like Yahoo Finance.


Vendors like TickData provide data files that aren't cheap, but they have complete data for most major markets.


Download as Much Historical Data as Possible


Once you've chosen the best software for your backtesting, now it's time to download historical data for your backtesting.


Many backtesting software packages have the ability to download data from their own data source, or upload third party data files.


Regardless of where you get the data from, you want to have as much clean data as possible.


This is because you should backtest in different market conditions, such as:



  • High volatility

  • Low volatility

  • Strongly trending markets

  • Weakly trending markets

  • Ranging markets

  • Unusual news events


The 2 highlighted areas on this AUDCAD chart illustrate very different market conditions.


Area 1 is a strongly trending market and your strategy could perform very differently in that market, compared to area 2, where the market is ranging.


So it's important to have as many historical scenarios as possible.


AUDCAD chart


There's a common myth on the internet that if a trading strategy is profitable after 100 trades, then it will work in live trading.


That's simply not true and 100 trades is certainly not enough to backtest a day trading strategy.


If you only backtest 100 trades, that usually won't cover more than a few weeks.


Here's a video that demonstrates why 100 trades isn't enough.



In reality, you should test as many trades as possible.


But it isn't feasible to backtest ALL of the trades in your historical data because there are so many potential trades with a day trading strategy.


The solution is to pick specific time periods that represent the different types of market conditions mentioned above.


If this is your first time backtesting a day trading strategy, then I would suggest picking a few 2-week periods to start testing.


Start with one 2-week period in a volatile market, one period in a ranging market and a third 2-week period in a random market.


This will give you a good feel for if a trading strategy has an advantage or not.


You should obviously do more testing than that later, but backtesting a day trading strategy can be overwhelming.


Starting with a few short periods will help you get into the flow and understand the process.


Backtesting in a few short historical periods will also save you time. 


You could spend a lot of time backtesting several months in the same market condition, like a trending market.


That wouldn't help because you won't know how the system performed in a ranging market.


When you test short periods in different market conditions, that will give you a better idea of how your strategy will work overall. 


Monitor Trading Expenses


There are 3 types of trading expenses that should be taken into account when backtesting a day trading strategy.



  1. Spread

  2. Slippage

  3. Commission


Whenever you're backtesting a day trading strategy, it's very important to take these factors into account because they can have a big effect on the profit of every trade.


For example, if you scalp in Forex, your biggest winners may be only 10 pips. Let's say that the average spread in the currency pair you're testing is 2 pips. If you don't factor in the spread in backtesting, then your strategy will be at least 20% less profitable than your backtesting shows.


There are different ways that you can factor in the expenses in a trade.


If you use a spreadsheet to record your backtesting trades, then you can add a column for expenses. Be sure to use accurate expenses if you use this method.


You can get spread and commission numbers from your broker.


To get approximate slippage numbers, take a few trades in a demo account at your broker, if possible. Be sure to take several demo trades at the time you'll be trading to get a good slippage estimate.


An easier way to estimate your trading expenses is to use backtesting software.


Many professional backtesting software solutions factor in the spread automatically and allow you to manually set slippage and commission in the settings of the software.


For example, NakedMarkets shows the current spread at the bottom of the screen.


Trading spread


This spread changes on every candle, according to the spread data in the file.


In the settings for each symbol, you can also set the spread and commission manually.


Spread and commmission


This is just one example, but other software packages have similar features.


Regardless of which method you use for backtesting, factoring in your trading expenses is vital in backtesting day trading strategies.


Backtest at the Right Times


Another important factor to take into consideration is the hours of the day that you take trades in backtesting.


Track the times that you'll actually be trading. If you take trades in backtesting that are outside of your normal trading hours, then your backtesting results will be inaccurate.


For example, if you take backtesting trades during the time you're normally sleeping, then there's no way that you'll be able to take those trades in real life.


The easiest way to track market times is to mark the market hours on your chart while you're backtesting.


Many backtesting platforms have the ability to do this.


For example, in NakedMarkets, you can add an indicator that marks the major Forex market open and close times.


Trading sessions indicator


If you use MetaTrader 5 to do manual backtesting, I've come up with a simple custom indicator that allows you to mark specific times on your chart.


This indicator will mark the same time every day on the 1 hour chart or lower. It can also send you alerts to your phone when the time period starts.


In this example, the marker shows the London open.


Time marker for MT5


Backtest Honestly


Now that you have a trading plan, backtesting software, data, and you know when to backtest, it's time to get to work testing.


If you backtest manually, do not move your chart forward to quickly. You don't want to pass a trading entry and have future information about a trade.


Even worse, some people will move their chart forward a few candles to see how a trade would have worked out, before taking a trade.


When you're doing manual backtesting, do your best to simulate real trading conditions and don't overshoot your entry.


Automated backtesting can also have pitfalls.


When you're optimizing an automated trading strategy, optimize your strategy on one set of data. But do more testing on other sets of data to be sure that you haven't over optimized your strategy to the test data.


For example, if you optimized your strategy in the years 1999, 2004 and 2019. You should also test your strategy in other years like 2003, 2008 and 2013.


Don't optimize over all years in your data file. 


Obviously, you should test during more years than that, but that's just a small example of how you shouldn't optimize your strategy on your entire data set.


Analyze the Results


Once you've completed your first round of backtesting, now it's time to review the results.


If you're using a spreadsheet, then calculate the vital statistics on your spreadsheet.



  • Win %

  • Maximum drawdown

  • Maximum number of losers in a row

  • Short win %

  • Long win %

  • Average Win / Average Loss

  • Graph of your performance


It can take some time to compile this information, but it's worth it.


If you use backtesting software that has built-in reporting, you'll save a lot of time because you won't have to manually calculate your statistics.


Here's a sample of the stats that NakedMarkets provides.


Backtesting stats


What to Avoid When Backtesting Day Trading Strategies


There are 2 main things to avoid when backtesting intraday strategies.


First, avoid trading software that doesn't have many years of backtesting data.


I love using TradingView as a trading and charting platform.


But as this is being written, it does not have enough historical data to do a proper backtest for a day trading strategy.


This may change in the future, but as it currently stands, they only provide a couple of years of data.


Second, avoid very complex trading strategies. They are hard to test and it can be easy to miss entry criteria when taking trades.


Complex strategies also have a lot of moving parts and those types of strategies tend to break down over time.


In general, the simplest trading strategies tend to work the best because the take advantage of basic principles of market dynamics.


If you avoid these 2 common mistakes, you'll have a much higher probability of finding a strategy that works over the long haul.


How to Know When You Should Go Live With a Strategy


Once you've tested a strategy, you might be wondering if it's good enough to trade live.


That's going to be a personal decision and it's up to you to determine if the strategy meets your goals and if you have enough confidence in it to risk real money. 


If you currently don't have a fully tested trading strategy, then it can be a good idea to start trading a strategy that has an edge, until you find a strategy that has better performance.


Even if a strategy doesn't have a huge return, you can use the power of compounding to build up your account while you test other strategies. 


But again, the final decision is up to you.


How Day Trading Backtesting is Different from Backtesting a Swing Trading Strategy


Backtesting a day trading strategy requires much more focus and diligence.


Expenses will have a much bigger impact on the profitability of a day trading strategy.


With a swing trading strategy, you don't have to worry about expenses as much and there is a larger margin for error.


However, there is a much higher potential to build your account quickly with a day trading strategy.


You could do both.


But you have to match your trading timeframe to your personality. Some people cannot handle day trading and others find swing trading too slow.


So take your personality into account and don't only try to make money quickly with day trading.


Final Thoughts


Backtesting is the best way to prove that a trading strategy has an edge.


If a strategy worked in the past, then it's very likely to work in the future.


Of course there's no guarantee that the strategy will work in the future. But if it never worked in the past, then there's no way that it will start magically working in the future.


I see way too many new traders take random trading strategies from the internet and start trading them with real money.


Just because someone on YouTube speaks with confidence and tells you that a trading strategy works, does not mean that it will actually work.


On top of that, the strategy may work for them, but it may not be a good fit with your trading personality.


So backtest everything for yourself. If you get positive results, then open a demo account or small live account and forward test the strategy.


If that goes well and you have confidence in the strategy, then you can start trading with your full account.


That is how you backtest a day trading strategy properly.


The post How to Backtest Day Trading Strategies appeared first on Trading Heroes.


Source: How to Backtest Day Trading Strategies