I tested Three SMA Offset strategies and here are their spectacular results! (Patreon)
Downloads
Content
Introduction
This time, I want to discuss a trio of strategies that have been showing very good backtest results and all end up very high on the Strategy League. They’re known as the 'SMA Offset' strategies and all have their own risk profile and great theoretical results, that might give you an edge in the market if you use them. So, let’s proceed quickly after the intro.
Strategies
So, In this video, I’m not just exploring one, not two, but three variations of the SMA Offset strategy. Each one tweaks the SMA Offset concept differently to optimize trading results. So ,whether you’re a seasoned trader or just starting with a trading bot, understanding these subtleties could be crucial for your trading arsenal.
I will discuss each strategy’s on a high level, delve into some specific parameters. Then I will discuss how these small changes can impact overall trading performance by showing the different end results after backtesting on the exact same setup I use for all my other backtests. My goal here is to understand which SMA Offset strategy stands out in terms of ease of use, potential profitability, and risk management for trading with a trading bot. Since manually trading these algorithms is too complex.
Where to find these files
If you want to use these files for your own setup, then you can easily find them on Github by searching for the name SMAOffset.
This will present you with a large list of repositories of people that have downloaded these files and added them to their own personal repos.
Code search results (github.com)
In this video I will show you the test results of the following versions:
freqtrade/user_data/strategies/SMAOffset.py at 983c099c47142bdec9b2fea9e7e1745c0dbd7d6d · akivacz/freqtrade (github.com)
strategies/SMAOffset_Hippocritical_dca/SMAOffset_Hippocritical_dca.py at 50adb2f3c12cc72e4f8d3ba7bfbaa90c059c9632 · hippocritical/strategies (github.com)
freqtrade-stuff/SMAOffsetProtectOptV1.py at 38652d3b222285329d88a5fc5418c47c412225a3 · thierryjmartin/freqtrade-stuff (github.com)
As you can see, I am not the author of these strategies, so all the actual credits and support go to the original authors. I’m just the guy that tests these algorithms on their merits and present you the results I’ve got on my specific setup. Informing you about the possibilities of these algorithms and taking this initial work out of your hands.
Code similarities and main differences
Now what about the similarities and differences between these different code files. The main commonality in the first instance is their name. And on first sight they all are evolutions of each other. Where the SMA Offset looks to be the initial version, the SMAOffsetProtectOpt builds on that and the DCA version is again an evolution of the ProtectOpt code.
Similarities
What about their other similarities.
These three SMA Offset strategies share several core features that define their trading mechanics. Each strategy employs Simple Moving Averages (SMA) to determine buy and sell signals based on price movements relative to the SMA with an offset.
They all use the 5-minute timeframe for operational decisions, indicating a preference for short-term trading.
The use of parameters like low_offset and high_offset to configure the buy and sell conditions is common across all versions, allowing for dynamic adjustments based on market conditions. Although their exact values all differ.
All three strategies are also capable of optimizing buy and sell parameter, besides the default stop loss and ROI settings.
And also the trailing stop loss has not been set for all three strategies. Which makes the backtest results seem to be more reliable to me.
I also tested all three versions on the possibility of lookahead bias.
But none of these versions seem to have a lookahead bias according to the test. So that’s another commonality.
Differences
Now, While these strategies share a common foundation, each one introduces unique elements that set them apart. The first strategy, SMAOffset, sticks to a more traditional approach with a simple stop loss and no trailing stop, focusing on standard SMA calculations.
The second strategy, SMAOffset_Hippocritical_dca, introduces complexity with dollar-cost averaging (DCA) tactics, of which I am not going into detail here. But the general idea here is that it adjusts position sizes based on the previous price movements and a dynamic calculation of safety order multipliers. This strategy aims to manage risk through a series of calculated incremental investments as prices fall.
In contrast, the third strategy, SMAOffsetProtectOptV1, incorporates protective measures like LowProfitPairs and CooldownPeriod to mitigate risks from low-profit trades and market cooldown periods, showing a sophisticated approach to managing unfavorable market conditions. Moreover, it leverages an informative timeframe to gather additional market insights, providing a broader perspective on potential trades. This strategy seems to be the most defensively oriented, aiming to protect the investment by preventing trades during identified risky periods.
SMAOffsetProtectOptV1 also uses an additional, longer informative timeframe (1h), which can provide insights into longer-term trends that might affect the trading decisions based on the 5-minute operational timeframe. This dual timeframe approach can enhance decision-making by aligning short-term trades with the broader market direction.
The EWO is utilized in the second and third strategies to provide additional market context. This oscillator helps in identifying the strength of market trends and potential reversals, which can be particularly useful in strategies that rely on moving averages by providing a secondary confirmation signal.
In essence, the progression from the first to the third strategy shows a clear evolution from a straightforward SMA-based approach to more complex and nuanced strategies incorporating additional risk management features and market analysis tools.
Does this increased complexity also increase the profitability and risk management of these algorithms or not? Let’s find this out in the backtest results section.
Backtest results
Smaoffset_hippocritical_dca Strategy backtest results
Let’s start with the most interesting trading strategy there is. The Dollar Cost Averaging trading strategy.
Just like every backtest I always test on multiple timeframes to see if a trading algorithm might perform better on another timeframe instead of that one that is configured in the code.
IN this case this algo actually performs better on the 15 minute timeframe than on the 5 minute.
Using this algo on the backtest data and timerange range provided a theoretical 150 percent gain. And it has a spectacular 97% win rate with a winstreak of 301 wins over a maximum losing streak of 5.
All other numbers on this timeframe also show that this algorithm seems to have high potential to make you money in the markets.
It has a very good looking equity curve.
With minimal drawdowns, so it seems.
If you wonder why you do not see the max drawdown shown in the table here. That is because I have limited the plot range here.
And you can see here on the win loss ratio plot that the amount of weeks with a loss is almost minimal here.
The strategy shows a high winrate with most values tightly clustered around 0.7 to 1.0, indicating that the strategy is consistently successful in making profitable trades most of the time.
Profit Distribution: The profit distribution indicates variability in the actual profit outcomes per week. While there are a few outliers with high profits, the bulk of the results lie close to zero, and some results are significantly negative, highlighting some weeks with losses.
Risk Assessment: The presence of outliers on both ends of the profit distribution suggests a degree of risk. The strategy can yield high returns but also bears the risk of losses, which could be a point of concern for risk-averse traders.
So overall this trading algorithm has good potential that should be tested out first in forward testing and possible further analysis of the advanced DCA methods and the exact way it works.
Everything that ends up in the upper 25 percent of this rather large growing list is gets an A-rating in my book. And this algo certainly earned its position.
Smaoffsetprotectoptv1 Strategy backtest results
However, The Smaoffsetprotectoptv1 Strategy sheds a whole different light on the performance of the DCA offset strategy.
The winrate on the best performing 30 minute timeframe, may not be 97 percent. But the overall way to capitalize on the market is clearly better. This is also visible in the performance ratios like Sharpe, Sortino and Calmar.
Although the equity curve is more jagged here, the curve line shows an over 45 degrees angle which ends over 50000 hypothetical backtesting dollars.
So overall there might be more downside risk and the performance of the strategy is more possibly prone to rapid changing market circumstances. These drawdown spikes are probably caused by the stop loss setting that might be too tight to let open trades breathe.
Since this is the main cause of losses when backtesting this algo.
This results in the boxplots shown here. These plots show us that this strategy has a relatively consistent winrate, with the majority of results clustered between 0.5 and 0.8. The complete range indicates a generally successful strategy but with a wider variability in performance compared to the previous strategy we analyzed.
The profit distribution reveals a significant range of outcomes, with a median close to zero but extending from very high gains to substantial losses. The presence of many outliers, especially on the positive side, suggests that while the strategy can generate considerable profits, it also risks significant losses.
Overall this broad spread in the profit distribution underscores a high-risk, high-reward nature for this strategy. Such a profile may appeal to traders who are willing to accept potential downsides for the chance of substantial gains.
So given the extreme values in both profit and loss, this strategy would require careful risk management strategies to mitigate potential losses, particularly if used in a volatile market environment. The strategy's risk profile should be thoroughly understood and monitored.
Nevertheless its overall performance scores higher than the DCA Offset strategy. And the with the current spot on the overall Strategy League I would give this version certainly a try on one of my Forward testing bots someday.
Smaoffset Strategy backtest results
Now there is a reason I wanted to show the results of the most simple SMA Offset strategy.
Clearly it is proven again that simplicity seems to perform way better than more complex algorithms.
Unfortunately, I do not have a clear explanation why this is the case here. And I will certainly do more research on why this version scores so much better then its other more advanced versions.
On some points its performances are worse than the other versions. Like the winrate, winstreak, Pairs ratio and profit factor. But the actual scores on the profit percentage and Sortino, Calmar, Sharpe and CAGR performance indicators are so much better.
Its also the only version that scores actually the best on its intended 5 minute timeframe. And the 6700 trades it made shows me it is also quite active too. So at first sight there are no signals that this version has some weird quirks here.
I have compared this performance on a slightly different dataset and time range with the other two versions on their best performing timeframes.
I wanted to see if this was a fluke. But it showed again that the performance on this trading algorithm outperformed the other two versions.
So how does the equity curve look like of the SMA Offset trading algo?
Again, it shows that ‘with greater risk, comes great responsibility’. Since the curve here is the most jagged of all three. By looking at the last part of the curve, it also shows that market sentiment might have the most influence on this algo’s performance too.
This is also clearly visible in the ‘sawtooth’ like drawdown plot.
And the weekly profit and loss chart also shows that this algo version can be subject to some dramatic weeks if market circumstances are against you.
The strategy exhibits a winrate distribution mostly between 0.6 and 0.8, with a few instances going as low as 0.3, and some outliers that are even lower than that. This indicates a generally successful strategy but with some inconsistencies that could result in periods of less favorable outcomes.
The profit distribution reveals a wide range, with a median profit slightly above zero. The distribution features outliers showing significant profits, but it also includes substantial potential losses, with outliers extending down to over -20000. This indicates a high variability in weekly profits, suggesting the strategy can be very profitable but also bears significant risk, which we already saw in the previous plot.
This broad range of results suggests a high-volatility strategy where careful risk management would be essential to mitigate potential large losses. And that’s where the major improvements of this algorithm are I think.
Also, given the high variability in distribution of both winrate and profits, this strategy might be suitable for traders who can tolerate higher risk for potentially higher rewards. The notable spread in the profit distribution underscores the importance of robust risk management practices when using this strategy.
When comparing the boxplots of the three SMA Offset strategies, a comprehensive view of their risk and reward profiles can be summarized as follows:
SMAOffset_Hippocritical_dca: This strategy shows a high winrate with consistent outcomes, but the profit distribution exhibits both significant gains and some losses. It balances moderate risk with the potential for high rewards, making it suitable for traders who seek consistent performance with manageable risks.
SMAOffsetProtectOptV1: Characterized by a broad winrate distribution and a wider profit range, this strategy appears to offer a high-risk, high-reward scenario. While it can generate considerable profits, the potential for substantial losses is also significant. This strategy may appeal to more aggressive traders who are willing to accept higher volatility for greater potential returns.
SMAOffset: Exhibiting a winrate with a lower floor and a profit distribution that includes extreme losses, this strategy is the most volatile of the three. It provides opportunities for high returns but at a higher risk, including the possibility of substantial losses. This strategy is suited for traders who are comfortable with high-risk setups and have strategies in place to manage large drawdowns.
But as already said, high risk also can provide you with high rewards too. Since the end balance of this SMA Offset strategy has the third highest gross profits. If I compare them with the other algorithms in the strategy league.
This SMA Offset performance brings the total score to such great heights that it enters my current Strategy League on the third spot. Which I think, is a great achievement.
On some performance indicators it might not be the ideal strategy to use and it is with great emphasis that you only should use these trading algorithms after careful investigation and testing. Taking into consideration your own risk appetite of course.
Overall Conclusion
As for these three specific trading algorithms:
Comparatively, the SMAOffset_Hippocritical_dca version offers the best balance between risk and reward, maintaining a high winrate while controlling profit variability. SMAOffsetProtectOptV1 and SMAOffset introduce higher risk levels but also the potential for higher rewards.
Choosing among these depends on a trader’s risk tolerance, capital management strategies, and trading goals. And the persons that want to use these algorithms must carefully consider how the volatility in winrate and profit distributions align with their investment criteria and risk appetite.
Ending
And with this conclusion I’m at the end of this post.
I have another three great algorithmic trading strategies added to my total Strategy League.
I am currently forward testing 5 of the current best trading algorithms and you can see on my live feed how they currently perform.
For now many thanks for reading the post, and I will see you in the next one.
Goodbye!