XaiJu
Dutch Algotrading
Dutch Algotrading

patreon


Testing the MultiMA_TSL5 : Is it worth to try out?

Introduction

In this blog post, I'll be exploring a sophisticated algorithmic trading strategy designed by STASH68, known as the MultiMA_TSL5

This strategy is built for the Freqtrade trading bot, utilizing multiple moving averages and a comprehensive set of buy and sell conditions, all finely tuned to optimize trade entries and exits. The MultiMA_TSL5 strategy integrates several advanced indicators, including the Hull Moving Average (HMA), Exponential Moving Average (EMA), and the Profit Maximizer (PMAX), to identify profitable trading opportunities in volatile markets.

Let's delve into the details of this strategy to understand how it operates and what makes it a potentially valuable addition to your trading arsenal.

The Strategies code

Let’s walk over the code first, like I usually do, and try to reverse engineer what the authors trading idea is to get an edge in the market. 

Let me begin first with the remark section. As said, this code is made by Stash86 and if you like his/hers work, then there are several ways to donate. 

I explored some of these donation addresses, but it seems that the author is not very active on Patreon. 

Also there also has been no donations send to the BTC address, ever…

Let me try to find out why this is the case and explore the code further. Maybe the algorithm isn’t that good after all…

The strategy begins by importing necessary libraries and modules. These include common technical analysis libraries like qtpylib, numpy, and talib for indicator calculations.

DataFrame and Series are imported from pandas for data manipulation.  DecimalParameter, IntParameter, and other similar imports are used to define adjustable parameters for the strategy, which allows for optimization during backtesting.

Logging and threading imports are included for debugging and potentially managing asynchronous tasks within the strategy.


The MultiMA_TSL5 class inherits from IStrategy, making it a valid Freqtrade strategy.

Also the version method returns the strategy's version, helpful for tracking updates and the use of the correct version of Freqtrade. 

 INTERFACE_VERSION = 3 ensures compatibility with the Freqtrade bot's current interface version. By the way, I still backtest on version 2023.07. So if you experience any problems with this strategy, than check your version since newer versions deprecated some older strategies functions…

The minimal_roi dictionary defines the return on investment targets, with "0": 100.0 indicating that the strategy will try to hold the position until it achieves a 100% profit, reflecting an aggressive profit-taking approach.

The buy_params and sell_params dictionaries store parameters that control the behavior of the strategy's buy and sell signals. For the buy conditions, parameters like base_nb_candles_buy_hma define the number of periods to consider when calculating the HMA, while low_offset_hma adjusts the entry threshold.

Similarly, the sell parameters like base_nb_candles_sell_ema define the EMA's length for sell signals, and high_offset_ema modifies the threshold for exiting trades.

These parameters allow fine-tuning of the strategy, optimizing for different market conditions.

Protection parameters are designed to safeguard against prolonged losses or significant drawdowns.

low_profit_lookback sets the lookback period for evaluating trades, and low_profit_min_req sets the minimum required profit during this period.

max_drawdown_allowed and similar parameters limit the maximum acceptable drawdown, while stoploss_guard_lookback manages the time window for stop-loss evaluation.

These parameters are critical for risk management, ensuring that the strategy stops trading when market conditions are unfavorable.

The protections property defines a list of protection mechanisms that the strategy uses to avoid poor trading periods. Each protection is implemented as a method, such as LowProfitPairs or MaxDrawdown, specifying how and when trading should be halted.  These protections are dynamically adjusted based on the parameters defined earlier, helping the strategy to automatically respond to adverse market conditions.

The populate_indicators_1d, populate_indicators_1h, and populate_indicators_15m methods calculate various technical indicators on different timeframes. These methods use decorators like @informative('1d'), which tell Freqtrade that these indicators are to be calculated on daily, hourly, or 15-minute timeframes, respectively.

For example, in populate_indicators_1d, the strategy checks if the volume has been consistently positive over a set number of periods, ensuring that there's sufficient liquidity in the market.  This multi-timeframe approach helps the strategy capture broader trends and validate signals across different time horizons.

The populate_indicators function calculates and stores various technical indicators that will later be used to determine the entry and exit points for trades.

Heiken Ashi Candles: The function begins by generating Heiken Ashi candles, which are a modified version of traditional candlesticks that smooth out price movements and make trends easier to identify. These candles are particularly useful in reducing market noise, helping the strategy to focus on the underlying trend rather than getting distracted by minor price fluctuations.

Profit Maximizer (PMAX): The strategy uses the PMAX indicator, which is a variation of the Parabolic SAR and moving averages, to define key support and resistance levels. PMAX helps in identifying whether the market is trending upwards or downwards. This indicator is crucial for both entry and exit decisions, as it determines the direction of the trend.

Relative Strength Xtra (RSX): The RSX is a refined version of the RSI, offering smoother and more accurate signals. The strategy uses two RSX values with different periods to capture both short-term and longer-term momentum. These values help the strategy gauge the strength of the trend and filter out weak or false signals.

Hull and Exponential Moving Averages (HMA and EMA): Multiple Hull and Exponential Moving Averages are calculated with different time periods and offsets. These averages are used to identify potential buy and sell signals based on the relationship between current price levels and these smoothed averages. The combination of HMA and EMA ensures that the strategy is sensitive to both rapid and gradual price movements.


The populate_entry_trend method generates buy signals by evaluating a series of conditions based on the indicators previously calculated. If these conditions are met, it marks the corresponding points in the DataFrame with an enter_long signal.

What I do find interesting is the way the author has programmed the following things into this buy signal function.

One example is its use of data from multiple timeframes. The strategy compares moving averages across different timeframes (15 minutes and 1 hour) to ensure that the broader market trend aligns with the shorter-term signals. This helps in filtering out trades that might look promising on a short-term chart but are not supported by the overall market direction.

Also the strategy looks for confluence among several indicators before deciding to enter a trade. For instance, it checks if the current price is below specific moving averages (like HMA and EMA) and if the PMAX indicator suggests a downward trend. It also requires that the RSX indicators are below certain thresholds, indicating that the market is not yet overbought and has room to move upwards.

And finally he strategy ensures that there is sufficient market activity (as indicated by low volume volatility) before entering a trade. This helps avoid entering trades during periods of low liquidity, which can be riskier.

The populate_exit_trend method similarly checks for sell signals, ensuring that trades are exited at the appropriate time.

And I can say almost the same thing about the exit signals here.

The strategy uses a set of EMAs with different periods and offsets to generate sell signals. For example, a sell signal might be triggered when the current price rises above a certain EMA and the PMAX indicates that the trend is weakening. This suggests that the upward momentum might be fading, and it's time to exit the trade.

Like the entry strategy, the exit strategy also relies on multiple layers of conditions. It checks several different EMAs and combines them with the PMAX and volume conditions to decide whether to exit. This layered approach ensures that the strategy only exits trades when there is strong evidence that the market conditions are no longer favorable.

In general, the exit logic is designed to protect against significant losses by triggering exits when the indicators suggest that the market is turning against the trade. By doing so, it helps in preserving gains and avoiding situations where a profitable trade turns into a loss.

To me this all looks like a pretty well thought out sophisticated trading algorithm that we can learn from. 

However the proof is in the pudding and no matter how sophisticated an algorithm looks, to me its more important that it performs well in comparison to the other trading strategies that I’ve tested earlier. 

So let’s backtest this baby and find out…

Backtest results

The backtest results for the MultiMA_TSL5 strategy, tested on the 5-minute timeframe only because of the informative timeframes, present a mixed performance, showcasing both strengths and areas for potential improvement.

End Balance: The strategy achieved an end balance of 1270.72, reflecting a profit of 27.07% over the backtesting period. It’s not astronomical, and quite disappointing, considering some of the other strategies that work on this short  5 minute timeframe.

Trades: The amount of trades is exceptionally low for a 5 minute timeframe. Backtested over a longer period. It looks like this algorithm does not manage to generate lot’s of trading signals on the 5 minute timeframe to get higher trading results and this is the most important thing I noticed from all these numbers.

Win Rate: The strategy boasts a 63.47% win rate, meaning that nearly two-thirds of the trades were profitable. This is a positive indicator, suggesting that the strategy can identify winning trades more often than not.

Max Drawdown: The maximum drawdown recorded was 3.43%, which is exceptionally  low. This indicates that while the strategy does experience losses, it manages to keep them under control, preventing significant depletion of the trading account during downturns. I am curious about the equity curve here!

CAGR (Compound Annual Growth Rate): Although the CAGR is a modest 0.08, it is important to note that this figure is based on a 5-minute timeframe. For short-term trading strategies, a low CAGR is not unusual, as these strategies typically aim for frequent, smaller gains rather than long-term compounding.

The strategy achieved a Total Score of 179.0, with 71.43% of the tested pairs showing positive results. This suggests that the strategy is broadly applicable across different market conditions and trading pairs, although it may require further optimization to improve its performance. Especially the way it generates signals.

The equity curve for the MultiMA_TSL5 strategy, as shown in the plot, reveals several insights into the strategy's performance over the backtesting period. While the strategy does demonstrate some periods of profitability, there are clear areas where it struggles, particularly when compared to other 5-minute trading strategies.

The strategy begins with a rather flat performance from early 2020 until around mid-2020, where both the cumulative profit (yellow line) and cumulative wins (green line) show little to no movement. This stagnation period indicates that the strategy was unable to capture significant trading opportunities during this time, which could be a result of market conditions not aligning with the strategy’s parameters.

A noticeable spike in cumulative profit and wins occurs around late 2020 to early 2021, coinciding with the significant bull market that drove up prices across the cryptocurrency market. During this period, the strategy performed well, as indicated by the steep rise in the yellow and green lines. This suggests that the MultiMA_TSL5 strategy is well-suited to capitalize on strong bullish trends.

One of the most significant criticisms of the MultiMA_TSL5 strategy is its apparent lack of adaptability to changing market conditions. While it performed well during the bull market, its inability to sustain profitability post-peak is concerning. This suggests that the strategy might be too heavily reliant on strong trending conditions and may not be robust enough to navigate sideways or bearish markets effectively.

Winrate Distribution: The strategy's winrate hovers around 60%, but it shows significant variability, ranging from 40% to 80% across different periods. While it can achieve high win rates, the performance is inconsistent, with potential for both perfect wins and complete losses.

Profit Distribution: The strategy’s median profit is close to zero, indicating a tendency to break even. While there are occasional significant gains, these are offset by frequent small profits and losses, along with the risk of notable losses, highlighting the strategy's inconsistent profitability.

The winrate and profit distribution plots reveal a strategy that is capable of delivering decent win rates but struggles with consistent profitability. The high variability in outcomes, combined with the risk of significant losses, suggests that the MultiMA_TSL5 strategy may require further refinement to improve its reliability and reduce the frequency of extreme negative results. For traders considering this strategy, these insights underline the importance of cautious implementation and continuous monitoring, especially in volatile markets.

The comparison of the performance with other trading algorithms is shown in the plot above. As you can see, the line stays flat in relation to other trading algorithms like the combined NFIv6 SMA strategy (that I will analyze in another video and Patreon post).

Strategy League

And If I compare the overall performance indicators of this strategy with these other, way better performing algorithms, then you might guess what my final conclusion is about this algorithm…

The MultiMA_TSL5 strategy, when compared to other tested strategies, falls short in several critical areas. It generates lower profits, has a modest win rate, and maintains a low number of trades, which is particularly problematic for a short-term trading strategy. While its drawdown is well-managed, the overall performance metrics indicate that this strategy is not as competitive as others, especially in a fast-moving market environment where frequent trading and higher profit potential are key. Significant adjustments or a reevaluation of the strategy's core components may be necessary to enhance its viability.

Conclusion and Final Thoughts on the MultiMA_TSL5 Strategy

After thoroughly examining the MultiMA_TSL5 strategy, it’s evident that while it has some strengths, particularly in controlling drawdowns, it falls short in other critical areas, especially for a 5-minute trading strategy. The performance metrics reveal a strategy that is somewhat conservative, possibly too much so for the dynamic and fast-paced environment it’s intended for. The lower profit percentage, combined with a modest win rate and an alarmingly low number of trades, suggests that the strategy might be missing out on opportunities or not fully capitalizing on market movements.

Compared to other strategies that have been tested, MultiMA_TSL5 lags behind in generating consistent and substantial returns. The profit factor and Omega ratio further underline its struggle to achieve profitability. These issues, coupled with its underwhelming total score, indicate that while the strategy has a foundation that could be built upon, it currently doesn’t match up well against more robust alternatives.

However on the Strategy League it still ends up in the middle of the list because of its strength of keeping its gains.

Lessons Learned and Recommendations

The results from this backtest highlight several key takeaways for traders and strategy developers:

Frequency Matters in Short Timeframes: A low trade count for a 5-minute strategy can be a red flag. The strategy needs to be more active to capture the numerous small opportunities that arise within such short intervals.

Profit Consistency Over Raw Win Rate: While a decent win rate is crucial, it’s more important for those wins to translate into substantial and consistent profits. The MultiMA_TSL5 strategy shows that a decent win rate alone isn’t enough if the profits are too modest or inconsistent.

Final Thoughts

The MultiMA_TSL5 strategy serves as a reminder that even well-constructed strategies can struggle if they aren't finely tuned to the specific demands of the market they are designed for. For those who are considering this strategy, it may require significant optimization or might serve better as a base for further development rather than a final product ready for live trading.

I appreciate your continued support and engagement with these posts. 

Remember, the journey to finding a robust and profitable trading algorithm is often iterative, involving continual testing, learning, and adaptation. I hope this analysis has provided valuable insights, and I look forward to sharing more in the future as we continue to explore and refine trading strategies together.

Until the next time, 


Goodbye!!


Comments

Didn't know that. But thanks for the info.

Dutch Algotrading

Thank you for these test results. FYI: Stash86 is very active on Freqtrade's Discord

Ron Klinkien


More Creators