Home Artists Posts Import Register

Downloads

Content

Introduction

Hello my dear Patrons. 

In this exclusive post for you, I want to present you with yet another algorithmic trading strategy that performed very well on my backtesting setup.

Since this is not a script for a video, and the audience (you!) is already well informed on my method of testing, I can keep the intro simple and can directly drill down to the nitty gritty of the algorithm and which special things I discovered.

You may already know that I do not create video’s of all the algorithmic trading strategies I found and test because creating video’s takes lots of times. Also sometimes these algo’s look so similar or are build on top of each other, that I think it is a waste of precious time to recreate almost the same video with some minor differences in results of algostrategy (sometimes only a few lines of code can make a big difference).

Anyway, this time it is no difference. My last video was about the SMA Offset strategy (actually I discussed 3 versions). This time my post is again for an offset strategy I had laying around. But I did not notice it  only just after the video was posted. 

So here, yet again, another SMA Offset strategy with a slightly different name.

Source

The trading strategy itself can be found in the (maybe already well known) repositories on github. 

The source is easy to find if you search for it’s name on Github: Code search results (github.com)

The author of the code is Jooopieeert#239 (don’t know what og means) maybe original source or so…

The Algorithm

Since I write for an experienced audience, I will keep the explanation of the code high level. After this I can dive right into the trading results after this.

There is one important thing that I have to tell you. The original strategy code has the trailing stop loss enabled. This gives a positive biased view on the performance of the algorithm which can lead to unexpected results if you will use the code in real trading (after forward testing ofcourse!!).

So I also created a version without the TSL enabled to get a more realistic view on the strategy performance and to also show you the difference in performance between these versions.

The SMAOG strategy operates on a 5-minute timeframe, ideal for day traders looking to capitalize on short-term market movements. It targets an ambitious 10% return on investment per trade, aiming for significant profits quickly. The strategy employs a protective stoploss at -23%, offering a balance between risk and potential reward, tailored for those comfortable with aggressive trading tactics.

The SMAOG strategy utilizes several technical indicators to guide trading decisions. It employs moving averages (SMA and EMA) to determine market trends and calculate dynamic price thresholds for buying and selling. Additionally, it uses the RSI (Relative Strength Index) for exit signals, particularly to identify overbought conditions. The strategy also dynamically assesses "bad" pairs based on historical price movements, helping to avoid unprofitable trades. These indicators collectively aim to optimize entry and exit points, enhancing potential profitability.

The populate_buy_trend method defines the conditions under which a buy signal is triggered:

EMA Crossover: A buy signal is generated when the 50-period EMA is above the 200-period EMA, indicating a bullish trend.

Price Above EMA: The closing price must be above the 200-period EMA, reinforcing the bullish market sentiment.

Non-Bad Pair Filter: The pair is not flagged as 'bad' based on predefined thresholds, which evaluate recent price drops relative to the close.

Price Below Adjusted Moving Average: The closing price needs to be below the moving average (defined by the buy_trigger and adjusted by the low_offset), suggesting a potential undervaluation.

Positive Volume: There must be trading volume to support the buy signal, ensuring there's enough market activity for the trade.

The populate_sell_trend method specifies the conditions under which a sell signal is issued:

Price Above Adjusted Moving Average: The closing price must be above the moving average calculated using the sell_trigger and multiplied by the high_offset, suggesting a potential overvaluation.

Negative Price Momentum or RSI Conditions: The sell condition is triggered if either the price is dropping compared to the previous candle (indicating a potential reversal), or the RSI is below 50 (signifying weakening bullish momentum), or the RSI is decreasing compared to its previous value (further confirming the momentum loss).

Positive Volume: The presence of trading volume is required, confirming that there is sufficient market activity to execute the sell order effectively.

So all in all, The SMAOG trading strategy is designed to capitalize on short-term price movements by using a combination of EMA crossovers and relative price positioning within the trend to identify buy and sell opportunities. 

It employs dynamic thresholds for entry and exit points to adapt to current market conditions. With safeguards like a significant stoploss and a focus on avoiding "bad" pairs, this strategy aims for calculated aggressive trades in a volatile market. The overarching goal is to optimize trading on a 5-minute timeframe, targeting quick profits while managing risks efficiently. 

So now that we know these workings, let me show you how this algo performed on my backtest settings with and without the TSL enabled.

Backtest results

TSL enabled

The TSL enabled algo has the following results:

However, if I compare this with the version where the TSL is disabled, you get totally other results:

However the endscore between these two versions are not that much different. Even better. Both 5 minute timeframes have almost similar end results. The only major difference is that with TSL enabled the 30 minute TF scores much better in general. Which then sits at the top of this table.

In general the difference in end balance between the 5 minute with TSL and noTSL is 1.5 times better with TSL enabled.

But comparing the overall best timeframes (30m and 5m) is my deal here. So let’s see what the difference looks like in equity curve:

Before the last bull run, the EC was barely rising. But after that bull market kicked off, this algorithm also made very good profits. W

hat’s also interesting is that, after the bull market turned into a bear market, yhis version and timeframe still managed to make profits. However, with the (almost mandatory) big drawdowns.

The 5 minute timeframe shows a complete different picture. After the bull market topped, the strategy lost its momentum. But the gains also remained on your account balance. Only a slight decline after the major bear market drop.

This also is reflected in the drawdown charts.

The TSL 30 minute version has some 12 to 15 percent drops over the last years.

But the NoTSL drawdown only shows a major rise while the 2022 the bear market was in full effect. Note that it looks worse then it actually is, since it is only a max 6 percent drawdown. When the average is around 1.7 percent…

Another important plot (besides all the others I always include in the download package) is the Winrate and distribution box plot. They tell a lot about the ‘profile’ of the trades that are made with these strategies.

TSL Winrate and Profit distribution

This strategy's winrate distribution shows a tight interquartile range (IQR), mostly between approximately 0.7 and 0.9. This suggests a consistently high probability of individual trades being successful. However there are a few outliers at the lower end, with winrates as low as around 0.2. These could indicate weeks where the strategy performed poorly or the market conditions were not favorable. But in total the median winrate is above 0.75, indicating that more than half of the time, the strategy achieves a winrate of 75% or higher.

Now the profit distribution plot shows a wider range of outcomes compared to the winrate. The interquartile range spans from small losses to profits of around $400, indicating variability in the weekly profit outcomes. There are significant outliers showing losses as substantial as -$3000, suggesting that while the strategy can be profitable, there are periods where losses can be severe. And the median profit is slightly above zero, suggesting that in a typical week, the strategy might not generate substantial profits but manages to stay around break-even.

Now what about the NoTSL version…

The winrate boxplot shows a robust and consistent performance, with the majority of weeks achieving a winrate between approximately 0.6 and 0.8. But there are significant outliers on the lower end, where the winrate drops to as low as 0.2, suggesting some weeks where the strategy performs poorly.

Next to this Winrate distribution is tie Profit distribution.

This plot is notably tight and largely positive, with most weeks yielding modest gains up to about $200. The strategy shows a more constrained loss profile compared to the previous strategy, with only a few notable outliers indicating minimal losses. The median profit is around $50, suggesting that the strategy, on average, delivers small but consistent profits weekly. And this acknowledges the equity curve I showed earlier.

So overall the TSL version scores pretty good on the 30 minute timeframe. 

Comparing its performance with the other top 10 strategies there are a few outliers on these performance indicators plot. Like the profit percentage CAGR and Calmar ratio. 

But the other indicators are comparable with the other, sometimes better performing strategies.

As for the NoTSL version.

Its performance does not reach the 30 minute TSL version’s score. But that is not the goal here. Since this algo test gives a less biased view on the overall (still hypothetical) performance on the backtest.

All in all I do think that this performance is up to par, given it’s relative simple algorithm. And on some indicators it performs better then those strategies that are in the top 10 of the Strategy League. For example, its win percentage, Sharpe and Sortino, profit factor and profitable pairs ratio are very good here.

The SMAOG strategy, with its trailing stop loss (TSL), demonstrates a high winrate with significant profit peaks, yet faces occasional severe losses. Conversely, the SMAOG_NoTSL version, lacking a trailing stop loss, offers more stable and consistent gains, albeit more modest, with a tighter profit distribution. Both strategies maintain high average winrates, indicating effective entry conditions, but the SMAOG with TSL experiences greater financial volatility, highlighting a trade-off between higher potential rewards and increased risk.

Strategy League & conclusion

On the Strategy League, these two versions are close by each other but the difference in the profit factor is quite large. The main reason why the NoTSL 5 minute version scores this high is on its risk aversion mechanisms.

So in the end it all boils down to the forward test of this strategy under real live trading circumstances. If the TSL version really does better in real life forward testing, then there is no doubt that this 30 minute timeframe one should be used. But only if you do your own research and forward tests!

It should also fit your risk appetite. My experience until now is that greater gains also come with greater risks. And this also fits the adagium “Scared money does not make money”. 

But again, all within the limits of your risk appetite.

So with this conclusion I am at the end of this post. 

Many thanks for being a Patron. And I hope that this coming bull cycle will bring you the fortune you deserve!

Until the next time!

Goodbye.


Comments

Kevin Strouven

Thanks for sharing ! With which ferqai model is this good to use?