Thursday, January 30, 2020

EMA(13) & EMA(48) vs SMA(20) & SMA(50) Backtest Results

I've always wondered whether the SMA 20/50 combo would be better than the EMA 13/48.5 combo that I had read about through etfhq.com. So I back-tested both with the following set of rules:


  1. Initial Equity of Php 100,000
  2. Maximum number of positions: 3 (so we can keep track of our stocks)
  3. Maximum allocation per stock: Php 30,000 (30% of initial capital)
  4. Back-test period begins from January 1, 2010 to January 1, 2020 
  5. Entry would be 1 day after the golden cross, at the open.
  6. Entry would be a golden cross + RSI(28) being above level 50 to check for momentum.
  7. Stop Loss percentage of -8%.
  8. Stop Loss if price closes below the slower moving average.
The reason I am opting for a 10 year back test vs a 20 year one is simply because I am not confident with my data prior to 2010. As they say in data analysis, "Garbage in, garbage out".

Below is the code I used on my Amibroker. I am no master in coding AFL so if you know how to code using Amibroker, please check if my settings are correct.



First up is the SMA 20/50. Here are the results:


To summarize SMA 20/50 Golden Cross Results:
  • Net Profit: 510.61%
  • Ending Capital: 610,614.67
  • Total Trades: 302
  • Winning Trades: 83
  • Losing Trades: 219 
  • Win Rate (winning / total trades): 27.48%
Keep in mind that the above results meant that only Php 30,000 was used to buy up shares even if we had more capital. If we were to use 30% of total capital each time to buy shares instead of a flat rate 30k, then the results are as follows:


  • Net Profit: 1009.53% (holy cow!!! that's the power of compounding for you!)
  • Ending Capital: 1,109,525.93
  • Total Trades: 286
  • Winning Trades: 86
  • Losing Trades: 200
  • Win Rate (winning / total trades): 30.07%


Next up, we have EMA 13/48 Golden Cross Results. I chose 48 instead of the 48.5 because Investagrams doesn't allow for decimals in their chart settings for moving averages. Also, I did an EMA(48) vs EMA(49) backtest over the same period, and the EMA(48) had better results.

So, EMA 13/48 Golden Cross with flat rate of 30k pesos purchase per stock:


To summarize EMA 13/48 Golden Cross Results:
  • Net Profit: 583.05%
  • Ending Capital: 683,046.60
  • Total Trades: 382
  • Winning Trades: 105
  • Losing Trades: 277
  • Win Rate (winning / total trades): 27.49%
If we were to use 30% capital instead of the flat rate, the results are as follows:
  • Net Profit: 1323.2%
  • Ending Capital: 1,423,015.75
  • Total Trades: 352
  • Winning Trades: 98
  • Losing Trades: 254
  • Win Rate (winning / total trades): 27.84%
Here's a side-by-side comparison:


And there you have it folks. EMA 13/48 has a slight edge over SMA 20/50, but in all honesty, both systems are profitable. You just need to decide which one you are more comfortable, and more consistent with.

Belated Happy Chinese New Year and may God bless your investments.

Cheers!
Weekend Trader