Backtesting is a term used in modeling to refer to testing a predictive model on historical data. Backtesting is a type of retrodiction, and a special type of cross-validation applied to previous time period(s).
We first need a strategy to backtest
Then, what is strategy?
A strategy is nothing but an idea on when to BUY and SELL?
Say, you are analysing NIFTY chart, and found that whenever NIFTY breaks previous day high, it moves higher most of the time, and you also found that after upside breakout, it rarely reverses and breaks day’s low.
Hooray! you got a BUY and SELL idea!
Buy = Price breaks previous day high
Sell = Price breaks day low
Even though you got an idea, you won’t trade straightaway because of fear.
what is the fear?
Whether it will work or not?
Though we will never going to know what will happen in the future, but we can check what would happened in the past.
Now you are entering in to the realm of backtest.
Next thing that you will do is, download data in excel sheet for past several months and check each day for your conditions, note down entry and exit prices, calculate profit and loss.
If the results are inline with your idea and expectations, your confidence in the idea will increase which will dim the fear ‘Whether it will work or not?’, and you will
move on to next stage ‘Live Trading’
Backtest doesn’t mean using sophisticated TA software, analysing past data manually with the help of excel is also a kind of backtest. But using computer software will help you to analyze large data with different combinations in very little
There are couple of questions which needs to be answered before you enter into a trade?
- When to Enter?
- When to Exit?
- Where to put stoploss?
- How many trades to take?
- How much capital to allocate for single trade?
- Quantities to trade?
Here comes the use of backtest, it will give you answers for the all above questions.
Because each data source uses different hardware/software to store the incoming streaming data from exchanges and uses different methods to compute OHLC from the stored data. Hence, if GDFL data shows Pin Bar at 10:15, then it may not be a Pin Bar in TrueData.
Normally this backtest deviations happens at lower time frames (Ex: 1min, 5min etc)
So, you should design your strategy to be data independent. Using higher time frames and avoiding chart patterns wherever possible will make your strategy data independent.
Also, you should use the same data source for backtest as well as live trading.
Make sure your data source is reliable, if the data is wrong or not reliable then your backtest result may also go wrong.
Compound backtest may show bigger returns, but in practical we may not be able to Buy/Sell such huge quantities.