The Exponential Moving Average strategy (Patreon)
Downloads
Content
Intro
In this post I will show you the results of tests where I try to find the best settings for a strategy where you only use the Exponential Moving Average. It is a follow up of my last post where I tried to find the best Simple Moving Average settings. The results can be used as a baseline for your own manual trading strategy or trading algorithm. I will show you the best three EMA lenghts and timeframes and I will give some suggestions to improve this strategy.
So let's jump right in.
Since trading derivates and futures in the Netherlands is getting harder and harder because of tightening legislation and enforced compliance by our national bank and the AFM on multiple crypto exchanges, my plans for finding the best algo over the complete spectrum of bot trading has changed somewhat as a result of changing circumstances.
I'm broadening my search to also find the best trading strategy that can be done manually as well. But since backtesting this manually is hard labor and very time consuming I will still try to change these into code to do automatic backtests to find out faster and more precice if a certain strategy works or not.
Actually I am going back to my initial idea for this channel and try to find out the best trading strategy whether it can be done by hand or with an automatic process like a trading bot.
So now this is said, lets not ponder too much about these new circumstances and dive right in to this trading strategy.
As said this is some kind of second part that follows my previous post where I only tested the Simple Moving Average on its probability to make money in the crypto market. And probably also in other markets too.
In this post will use the Exponential Moving Average and will use the most common lengths according to Investopedia to see on which timeframe and which EMA length we should start with our base strategy and build up from there.
The strategy
The trading strategy is as simple as can be. And in this test I will use 50 different crypto pairs over all available date up until 2023. I also will still do tests on spot and futures trading on multiple timeframes since many of you do not live in these tightly regulated circumstances in the Netherlands.
As for the trading strategies here I will only use the following rules:
EMA lengths
I will test the following most used EMA lengths:
12 period
26 period
50 period
200 period
Spot trading
Trade entry
For spot trading where only long trades will be made there are two strategies:
- The first trading strategy does long buys when the closeprice crosses above the simple moving average.
- And the second variant does long buys as long as the closeprice is above the simple moving average.
So in the first case there is only one buying opportunity and that is exactly at the crossover moment and no candle before or after.
In the second case there can be a long buy as long as the close price is above the EMA. But in both cases there is no buy long trade when the close price is below the EMA.
Trade exit
- The trade exit will be if there is 100% profits reached or
- if the close price gets below the EMA
There is no stop loss set. The trade will be stopped when either of these two conditions are met.
Futures trading
I will also do a futures test where both long and short trades are made.
Here the rules are also simple. In this case I trade both ways:
- The first trading strategy does long buys at the crossover above the EMA and short sells at the crossover below the EMA.
- The second version will buy longs as long as the price is above the EMA or sell short as long as the price is below the EMA.
Trade exit
- The long trade will be exited when the price goes below the SMA
- the short trade will be exited when the price goes above the SMA and
- in both cases where there is 100% reached with the ROI setting.
So now that we know the rules of the game, let me test all these different lengths on multiple timeframes and see if there is much difference in comparison with the SMA strategy results.
Is above strategies Futures
EMA12 Futures
(isabove_ema12_f.py)
EMA26 Futures
(isabove_ema26_f.py)
EMA50 Futures
(isabove_ema50_f.py)
EMA200 Futures
(isabove_ema200_f.py)
Is above strategies Spot
EMA12 Spot
(isabove_ema12_s.py)
EMA26 Spot
(isabove_ema26_s.py)
EMA50 Spot
(isabove_ema50_s.py)
EMA200 Spot
(isabove_ema200_s.py)
Crossed above strategies Futures
EMA12 Futures
(crossedabove_ema12_f.py)
EMA26 Futures
(crossedabove_ema26_f.py)
EMA50 Futures
(crossedabove_ema50_f.py)
EMA200 Futures
(crossedabove_ema200_f.py)
Crossed above strategies Spot
EMA12 Spot
(crossedabove_ema12_s.py)
EMA26 Spot
(crossedabove_ema26_s.py)
EMA50 Spot
(crossedabove_ema50_s.py)
EMA200 Spot
(crossedabove_ema200_s.py)
Best version 3 - Is above/below EMA26 Futures
The first EMA strategy that has the best results with these tests is the is above and is below EMA26 on the 4 hour timeframe.
The profit curve shows, as the indicators name implies, an exponential growth during the last bull run. The line remaind reasonably stable from that moment on and hovered between 15000 and 20000 US Dollar.
Just as with the Simple moving average, this indicator will suffer from a low win rate and sometimes depressing losing streak.
And I will tell you beforehand that all other best EMA lengths and timeframes will have the same issue. So I will tell this only once. Just remember what I told you a minute ago and make use of additional rules or indicators to filter out the bad trades.
The drawdown of this version is 33% at its peak and has an average drawdown of 10 percent over the backtesting period. But expect regular drawdowns of around 20 percent in your account balance here and there.
The wins and losses per week can vary pretty heavy. Which also has an effect on the profit balance and the drawdown ofcourse.
And it looks like this EMA length and timeframe favour the altcoin pumps of Doge, Solana and Avax the most...
Best version 2 - Is above/below EMA50 Futures
The second best EMA length and timeframe are the EMA 50 on the 4 hour where long or short trades can be made on the pair as long as the price is above or below the EMA.
The Calmar, Sortino and Sharpe ratio also favor this way of trading with high scores overall.
In this case the profit curve seems to be even steeper than the EMA26 and it even goes higher when the bear market started after the market high.
In contrary to the previous best EMA, here the largest drawdown happened early, around 2020. And after that seem to not go higher than 20 percent anymore. The average drawdown here is less then 10 percent.
Another thing here is that the length of the longest drawdown period is way more shorter than that of the EMA26, as you can see on this plot:
In this case the well know alts have the highest gains here. And the most remarkable thing I can find is that trading bitcoin even provided the most losses. How peculiar...
This proves somehow that the real money is not being made by trading bitcoin but by choosing the correct alts. Bitcoin can be used more as an inflation hedge than as a medium to attain your greatest wealth so it seems.
Remarks
Now that we know the third and second best EMA length and timeframe, it is time for some general remarks about this and also other backtest results in general as well. Because I still get comments on these backtests from people that do not know the reasons and principles behind these tests I do.
This is a backtest
The first remark I want to give is that this is a backtest over historic data and does not guarantee profits in the future. It is a hypothetical excersise that gives insights in the possibilities and probabilities of a trading strategy.
Moving indicators are lagging
Now about this specific strategy.
Since a moving indicator is based on data from the past it therefore shows you the situation in a rear view mirror. They will not say which direction the price is going to be tomorrow. But they will give you insights on overall market trends.
A new trader might not know this, but if you have some experience I assume you know this and take this into consideration when using an indicator like this.
Use it as a baseline
Therefore you can use it as an initial indicator or rule that helps you form a baseline. Once you have a baseline that performs well to your own standards and risk appetite, then ...
Add other rules and confirmation indicators
You can use additional rules or confirmation indicators to filter out bad trading decisions, keeping only those that have a higher probability for a winning trade. But even then there is the risk of having losing trades.
Also the type of strategy plays a factor here as well. In my personal experience, swing trading strategies tend to have lower winrates but winners have higher gains, as long as you have the courage to let them run.
The reason for these low winrates is that price can zigzag around a moving indicator for a long time. Creating false trades that eventually end up losing because of your trading rule that says to exit if a price is crossing the indicator in the opposite direction of your trade again.
So that's why using another indicator or rule to filter out these false trades can be very beneficial.
Test, test, test
So after you have seen one of my videos or posts, please backtests, forward test and analyse on your personal setup and trading environment, and please remember that all these tests and analysis do still not guarantee anything. It only gives you more insights in the probabilities of your future trades.
So having said this, lets continue with the best EMA setup that I have found:
Best version 1 - Is above/below EMA200 Futures
Is it a strange coincidence or something else? Again the 4 hour timeframe has the best cards to provide you the highest probability for a good trading strategy.
From the 16 versions I tested, 9 of them have the 4 hour timeframe as the best for trading an EMA strategy on.
And they also are more in the top half of this list than in the bottom half. For me this is valuable information to build further on these baselines
The profit curve looks like a rocket sometimes with these truly exponential gains. But can also crashland and take you back to earth.
This is also noticable with the drawdown curve, where peaks of high drawdown occur many times. But in comparison to the previous two EMA winners, the drawdowns here do nog com higher then 2- to 22 percent or so. Even the average drawdown is lower than the other EMA lengths.
So it might also be an optical illusion that might seem this EMA length look so jagged to me.
Comparing the other performance indicators of this EMA length, shows that some factors still show pretty good numbers here.
Like the profit factor for example. But also the Calmar and Sortino score well here. But still improvements can be made on some important factors like win percentage, the amount of pairs that react well and still maybe the drawdown.
These are the areas you have to dig in to, to find out where the weak spots are and to improve on the performance.
But what strikes me the most here is the results of this best EMA version in comparison to its other Moving Average sibbling. The Simple moving average.
Strategy League
Because if I take a look at the Strategy League, I see that this EMA200 version performs better than the SMA200, according to the tests I did.
Now I am comparing both versions with the 200 length and not the SMA 100 since that length was not mentioned on the website.
But I can imaging that, if it was mentioned and I would test it, than it could certainly outperform the SMA 100 strategy.
And that is maybe an excersise that I want to give to the audience. To find out if the EMA 100 indeed proves to perform better than the SMA 100. It does not have to be exactly my setup. But testing this on your own setup can certainly help you understand this baseline strategy better.
Ending
So, I hope you liked the my test and analysis in this post and learned something from it.
Please remember that all results are just hypothetical and based on backtest information. Future results are not guaranteed.
All the testing logs, the strategy code of all these EMA variants and even more plots to analyse these results are available on my Patreon site.
Thank you for watching this reading this post until the very end and I will see you in the next one!
Goodbye!!