Truth in Backtesting (Part 5)
Posted by Mark on December 4, 2012 at 07:40 | Last modified: November 23, 2012 05:38I am discussing different ways of representing trading rules to understand the truth in backtesting: what allows for consistency with live trading and what does not.
Trading rule #1 was discussed in http://www.optionfanatic.com/2012/12/3/truth-in-backtesting-part-4.
Trading rule #2 is to buy at the close if today’s close is greater than yesterday’s 20-MA. Yesterday’s 20-MA is known after yesterday’s close but today’s close will not be known until after today’s close. If price heading into the close is near yesterday’s 20-MA then tomorrow’s open would be the soonest I could execute this trade with certainty.
Trading rule #3 is to buy at the close if today’s open is greater than yesterday’s 20-MA. Both yesterday’s 20-MA and today’s open are known by today’s close. No problems here.
My observation has been that most people who backtest trading rules write code to match trading rule #1. This applies to crossovers of indicators such as Bollinger Bands, MACD, or RSI. This also applies to crossovers of indicators above or below a critical value. In all cases, I truly do not know indicator values or the closing price until after the close, which leaves great opportunity to trade when I shouldn’t have (or vice versa) if I trade without delays. This will result in performance departure from backtesting results if the backtesting was not performed correctly.
Trading rule #1 is easiest to write and seems to scream loud and clear “buy on a close above the moving average,” but once again I need to stop and analyze at the moment of execution to see if it makes sense. In this case it does not. Taking the easy way out is never in my best interest (see http://www.optionfanatic.com/2012/10/18/laziness-dissected). The only one who stands to be hurt is me when I implement a trading system that looked great in backtesting only to realize much fewer profits or significant losses when I start trading it live.
Categories: System Development | Comments (1) | Permalink