All modulesModule 7 of 9
Overfitting
Try 50 settings on the early years, keep the top scorer, then see how it did on the later years it never saw. Repeat on several stocks.
Do this first
Try 50 settings, keep the top scorer
The EMA crossover has two knobs: the length of the fast average and the slow one. The experiment tries 50 combinations on the early part of the stock's history (the first 70% of up to ten years), keeps whichever made the most after costs, and only then looks at how all 50 did on the later 30% that played no part in the choice.
Up to the last 10 years of daily prices, ₹1,00,000 per trade, real charges and slippage.
Read it
Why the top scorer of many disappoints
Overfitting is fitting a strategy to the noise of one stretch of history rather than to anything that repeats. Every setting's result is part skill (if there is any) and part luck: which trends happened to come along, which crossovers happened to land on a good day. When you try 50 settings and keep the top scorer, you are mostly keeping the luckiest. The luck does not come with it into the future.
The part of history used to choose is called in-sample; the part held back is out-of-sample. Only the out-of-sample result estimates what choosing this way would really have earned. The gap between the two is the price of the search.
Repeat it
Does it happen on other stocks too?
One stock could be a fluke. Run the identical experiment on eight large NSE stocks (yours first) and count how often the chosen setting held up.
Check yourself
0 of 3 right
1. You try 50 settings on the same history and keep the top scorer. Why is its result probably too good?
2. What is out-of-sample data?
3. The top-scoring in-sample setting did much worse on the later years. What is the honest estimate of the strategy?