What is the best way to backtest a trading strategy?

Generally, people tend to optimise or overfit during backtesting to get the best results.

Foward test rather than Backtest!!

Any technical analysis or models would work best in a specific pattern or market conditions. So when you build a strategy, understand for which market conditions it is built (Uptrend, Downtrend or Sideways). For example, if your strategy is a trend following there should be conditions in the strategy which can identify non-trending market conditions to avoid them, if you are testing on specific stocks or your model should be able to select those stocks which are trending.

Let’s take a simple example:

Super Trend is an amazing trend following indicator and works best in trending market. We did backtest with the super trend with below conditions:

Buy: Supertrend (14,3) < Close

Sell: Supertrend (14,3) > Close

Long-only strategy on 15 mins candle with a capital of Rs.100,000 allocated equally to Reliance, SBI and ICICI Bank.

Here are the results:

Since the super trend is a trend following indicator, we need another indicator to identify the trend.

Hence, added Commodity Channel Index (CCI), which identifies the momentum in the stock. So now we are using CCI to identify the momentum on 60mins Candle.

Revised Condition: Take a position in stock using super trend on 15 min candle provided CCI on 60mins candle > 100.

NP changed from 2% to 35% and the number of trades reduced to half.

An ideal way would be to screen the stocks from the universe of say NSE50/100/500 using CCI and take positions using the strategy.

Above example was just to give an approach to build a model rather than the rules.

Disclaimer: The above content is purely for educational purpose and should not be used as investment advice.