JoelWarby

How to Backtest a Trading Strategy

Education
OANDA:EURUSD   Euro / U.S. Dollar
Backtesting is a manual or systematic method of determining whether a trading strategy or trading setup has been profitable in the past.

A trader should backtest a strategy to help determine if a trading strategy is likely a waste of time and money, or if it shows promise and profitability in a variety of markets.

While you can get software that does systematic backtesting… we prefer manual backtesting as it can be carried out by any type of trader,

It is a key component in developing an effective trading strategy. There are infinite possibilities for strategies, and any slight alteration will change the results. This is why backtesting is important, as it shows whether certain parameters will work better than others.

What Do I Backtest?
The first thing to note is that you don’t need a full trading strategy in order to start backtesting. 

For example I personally am always looking at new trading setups and candlestick formation and then backtesting them to see how effective they are. 

You can test small parts of a trading strategy before putting them all together. 

And of course you can and SHOULD backtest your whole trading strategy in a number of different trading situations. 

How to Backtest

 1) You need data to use in testing… if you are testing short term strategies on small timeframes then use at least a few weeks of trading data.

If you are using higher timeframes then you should be using years of trading data.

 2. Define the strategy parameters. Entry conditions, exit conditions etc. Include as many “If X happens then I will do Y” scenarios as possible so that your strategy is repeatable. 

Its essential to include risk management in these parameters too. So decide on if you are risking a percentage of your account equally on each trade, what is that percentage. If you are managing your risk in another method, clearly define it as something you are able to measure. 

ALL OF THESE PARAMETERS ARE WHAT YOU ARE MEASURING AND TESTING. THESE ARE THE ELEMENTS THAT YOU CAN CHANGE TO SEE WHICH ARE MORE OR LESS PROFITABLE.

3. Use the TradingView rewind tool to go back in time and remove the predictive nature of knowing where the chart will be headed. 

You could go back in time and look for trades from a year, a month or a week in the past, depending on how far back you wish to look.

4. Analyse price charts for entry and exit signals. This can be done until all trades on the chart up to the current time have been located and marked or written down

(be aware that it can take some time and be prepared that you are unlikely to be able to do all of this backtesting in one session… it could take you a few sessions of backtesting and recording the trade outcomes to fully test a strategy.)

5. Once you have competed this process, then you can start to total all of the trade results up to see how profitable or unprofitable your trading strategy / setup has been over time.

What Goes Wrong in Backtesting

Typically the pitfalls and the ways that people fail at backtesting are based around not being through enough. 

That could mean that people haven’t included enough data in the backtest. 

It could mean that they left too many unknowns in the strategy so when using it in a live trading situation the strategy isn’t usable or realistic.

Also it could be that people don’t back test for long enough to see if the strategy is profitable or not. If you only have a small sample size of trade then even a short losing or winning streak of trades would dramatically affect the results. You need enough trades to show winning streaks, losing streaks and all between so that you can be confident that your strategy will be able to withstand those situations in live trading. 

Imagine for example in your backtesting your strategy didn’t lose more than 2 trades in a row but when you start using it in live trading you get 5 losses in a row. This is a situation that hasn’t been tested so could show a different result. 

The goal is to backtest for long enough and through enough so that nothing in live trading hasn’t been tested previously. While it may not be possible to fully achieve this… it should be the goal and you should feel confident enough that you have done everything possible to ensure this is the case.


Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.