sobat.investor ๐Ÿ“– Book Home
โ† All articles

Education · Sobat Investor

Backtesting.

How to test a stock strategy honestly and scientifically, for retail investors on the Indonesia Stock Exchange (IDX).

Every trading strategy sounds plausible when someone tells it to you. "Buy when the price bounces off the 0.618 Fibonacci level." "Enter when RSI drops below 30." "Follow the smart money." The problem is that a plausible story and a money-making strategy are two different things. Backtesting is the bridge โ€” or the chasm โ€” between them.

This article explains what backtesting is, why it matters for retail investors on the Indonesia Stock Exchange (IDX), and โ€” the part most often overlooked โ€” how backtests can lie, and how to read them honestly.

The big picture: a backtest is an experiment, not a prophecy

A backtest, at its simplest, means taking a buy-sell rule, running it against historical price data, and calculating what would have happened had that rule been followed exactly. The result is a number โ€” return, maximum drawdown, win rate โ€” not an opinion.

This is what separates an evidence-based approach from market pseudoscience. A pattern that "always fits after the fact" can never be honestly tested, because there's always a new explanation for every outcome. A proper backtest forces you to commit to a rule before seeing the results, and then accept whatever comes out. It can prove your favorite strategy is actually useless โ€” and that's a feature, not a bug.

But there's one uncomfortable truth to hold onto from the start:

A good backtest does not guarantee a good future.

Markets are non-stationary and reflexive โ€” the rules of the game change, and the more people who trade on the same signal, the thinner its edge becomes. Even the most honest backtest only gives you a distribution of possibilities, not a certainty.

Why IDX retail investors should care

Without backtesting, you're testing a strategy with real money in real time โ€” the most expensive way to learn there is. Backtesting gives you three things:

Reading backtest results honestly

A headline "300% profit" number means nothing without context. Here's what actually matters:

Seven traps that make a backtest lie

This is where most backtests โ€” including the ones used to sell "miracle systems" โ€” fall apart.

1. Overfitting (a forced-fit curve). If you tweak parameters until the results look perfect in the past, you haven't found a strategy โ€” you've memorized history. A strategy with 10 parameters that all happen to line up almost always fails on new data. Bailey et al. (2014) even showed that impressive simulated performance is easy to achieve just by trying a small number of configurations โ€” and the more configurations you try, the greater the chance the result is illusory.

2. Look-ahead bias. Using information that wasn't actually available at the moment the decision was made. A classic example: using that day's closing price to "decide" to buy that same morning. In the real world, you don't yet know the closing price.

3. Survivorship bias. Testing only on stocks that still exist today, while ignoring issuers that were delisted or went bankrupt. This makes results look far rosier than reality, because the failures have already been "erased" from the data โ€” an effect strong enough to create an illusion of consistency (Brown et al., 1992).

4. Data snooping / p-hacking. Trying 200 strategies, then showing off the single best one as if it were a discovery. Statistically, out of 200 random attempts, something is bound to look brilliant โ€” purely by chance. Sullivan et al. (1999) demonstrated this while testing thousands of technical rules at once; Harvey et al. (2016) found a similar problem among hundreds of "factors" claimed to predict returns โ€” most fail to hold up once corrected for multiple testing.

5. Ignoring real IDX costs. This is the silent killer. Broker buy/sell fees, sales tax, the bid-ask spread, and slippage all erode returns. A strategy that trades frequently can look profitable on paper but lose money after costs.

6. Ignoring liquidity and market mechanics. A backtest often assumes you can buy or sell any amount at any price. On the IDX, second- and third-tier stocks can be thin โ€” a large order moves the price by itself. Then there's ARA/ARB (upper/lower auto-rejection): when your signal says to buy on a day the stock is locked at its upper limit, in reality you don't get filled at all.

7. Regime change (non-stationarity). A strategy that wins in a trending market can be destroyed in a sideways one. The data from 2014โ€“2019, the 2020 crisis, and the post-2021 period behave almost like three different markets. A backtest on one regime is no guarantee for the next. This is the core of the Adaptive Markets Hypothesis: a strategy's efficiency and edge evolve as conditions and market participants' behavior change (Lo, 2004).

How to backtest correctly

If the traps above sound alarming, here's the good news: all of them can be avoided with discipline.

A checklist before you trust a backtest

Before putting money behind any strategy โ€” your own or one someone else is selling โ€” ask:

  1. Was the rule defined before seeing the results, or fitted afterward?
  2. Was it tested on data not used to design it?
  3. Have costs, tax, slippage, and liquidity been accounted for?
  4. How many trades โ€” enough to be statistically meaningful?
  5. Is the profit consistent across years, or does it depend on one event?
  6. How deep is the drawdown, and can you actually stomach it emotionally?
  7. Does the presenter show the failures too, or only the best result?

If a "system" can't answer these questions openly, it isn't a tested strategy โ€” it's a story being sold.

Closing

Backtesting is neither a crystal ball nor a scam โ€” it's a discipline. Used honestly, it tells you whether a strategy would have survived real market conditions, at what cost, and with what risk. Used dishonestly (tuned after the fact, stripped of costs, cherry-picked periods), it tells you nothing except what you wanted to hear.

This is the standard we hold ourselves to at Sobat Investor: state the methodology plainly, disclose the traps, and report uncertainty as it is โ€” not as we wish it were.

References & Further Reading

The concepts in this article synthesize established quantitative finance literature, adapted to the IDX context. The list is split into sources directly cited and further reading.

Cited references

  • Bailey, D. H., Borwein, J. M., Lรณpez de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458โ€“471.
  • Brown, S. J., Goetzmann, W. N., Ibbotson, R. G., & Ross, S. A. (1992). Survivorship Bias in Performance Studies. Review of Financial Studies, 5(4), 553โ€“580.
  • Harvey, C. R., Liu, Y., & Zhu, H. (2016). โ€ฆ and the Cross-Section of Expected Returns. Review of Financial Studies, 29(1), 5โ€“68.
  • Lo, A. W. (2004). The Adaptive Markets Hypothesis: Market Efficiency from an Evolutionary Perspective. Journal of Portfolio Management, 30(5), 15โ€“29.
  • Lรณpez de Prado, M. (2018). Advances in Financial Machine Learning. Hoboken: Wiley.
  • Sharpe, W. F. (1994). The Sharpe Ratio. Journal of Portfolio Management, 21(1), 49โ€“58.
  • Sullivan, R., Timmermann, A., & White, H. (1999). Data-Snooping, Technical Trading Rule Performance, and the Bootstrap. Journal of Finance, 54(5), 1647โ€“1691.

Further reading

  • Bailey, D. H., & Lรณpez de Prado, M. (2014). The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting and Non-Normality. Journal of Portfolio Management, 40(5), 94โ€“107.
  • Brock, W., Lakonishok, J., & LeBaron, B. (1992). Simple Technical Trading Rules and the Stochastic Properties of Stock Returns. Journal of Finance, 47(5), 1731โ€“1764.
  • Chan, E. P. (2021). Quantitative Trading: How to Build Your Own Algorithmic Trading Business (2nd ed.). Hoboken: Wiley.
  • Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383โ€“417.
  • Harvey, C. R., & Liu, Y. (2014). Evaluating Trading Strategies. Journal of Portfolio Management, 40(5), 108โ€“118.
  • White, H. (2000). A Reality Check for Data Snooping. Econometrica, 68(5), 1097โ€“1126.

This article is educational and does not constitute investment advice. Investment decisions and their risks are entirely your own responsibility. Past performance does not guarantee future results.