XaiJu
Dutch Algotrading
Dutch Algotrading

patreon


Decoding the EI3v2_tag_cofi_green Strategy

In this blog post, we will dive into the EI3v2_tag_cofi_green strategy, a Freqtrade-based trading algorithm that employs various indicators and parameters for generating buy and sell signals. This strategy is an interesting combination of custom indicators, traditional technical analysis tools like RSI, and advanced features such as trailing stop losses and dynamic profit-taking.

Introduction

Before I discuss the strategy code and show its results. I want to do a quick shoutout to tang tang that pointed me to this algorithm. 

You can download the algorithm from here or search for it on github: https://github.com/search?q=EI3v2_tag_cofi_green&type=commits


In the code there are two mentions of the original authors here: Rallipanos and some changes made by IcHiAT. So all the kudo’s go to these developers. I’m just the guy who tests the algo on its merits and show you the results in this video.

The strategy

The strategy itself is designed to work on a 5-minute timeframe and also uses higher timeframes (1 hour) to form a more high-level view of the market. 

By using a combination of the Exponential Moving Average (EMA), Relative Strength Index (RSI), and the Elliot Wave Oscillator (EWO), it attempts to optimize both entry and exit points to capture profitable trends. 

But let me break this code down into sections and discuss every important part on a higher level here for more insights.

Here, we see the ROI (Return on Investment) table. This ROI table is time-based. However if you look closely at it, it has """ in front and behind it. Meaning that this is actualy a Python comment section. The real used ROI is used later on.

In this piece of this strategy are its buy and sell parameters, where the strategy is able to make use hyperparameter optimization if you use this option.

For the people that first hear this. In Freqtrade, hyperoptimization allows traders to automatically search for the most effective parameter values by backtesting thousands of combinations. However it also introduces a bias called curve fitting, so you should be aware that using optimization techniques on past data will not guarantee future success.


Now this section defines a set of protection mechanisms aimed at reducing risk and avoiding unprofitable trades. It includes safeguards like a cooldown period after trades, maximum drawdown limits to halt trading if losses exceed 20%, and various forms of stoploss guards and profit checks to prevent trading when certain conditions—like low profits or excessive drawdowns—are met. So to explain this in short: These protections help mitigate potential losses during volatile or unfavorable market conditions. Let’s hope we never need these…

Ths stop loss has been set to -0.99 which effectively disables the stop loss. From this point on I assume there will be other triggers in the code that provide the exit signals that replace the stop loss.

In this piece the ROI also has been set to 0.99. This means that at 99% profits the algo executes a sell. Locking in 99 percent profit.

However if the developers try to lean on the trailing stop loss here, then they have to be aware that enabling this while doing backtests can skew the output results to a more positive bias then originally is the case. I disabled it in this case to get more reliable results in my test. But remember, the original code has this set to True.

.

In this section of the strategy, several parameters are defined that control the behavior of the algorithm, many of which are optimized to find the most effective values. Overall, these parameters illustrate the complexity and flexibility of the strategy, with the ability to fine-tune almost every aspect of trade execution through optimization. This allows the bot to adapt to different market conditions and enhance performance.

In this small configuration section there is set that the bot may use the first 400 candles. But only trade after them. This is set so that some indicators can process  all this information to create the actual indicator output. In this case it is 400 candles of each 5 minutes, so the bot will start really working around 1.5 days after the start.

The pump_dump_protection function is designed to detect sudden, abnormal spikes in trading volume, which are often signs of pump-and-dump schemes. In short, It compares short-term and long-term volume averages to identify unusual volume increases. The function calculates the percentage change in volume over different time frames (24 and 36 hours) and triggers a warning (pnd_volume_warn) when the short-term volume exceeds the long-term volume by more than 5 times. This helps the bot avoid entering trades during potentially manipulated market conditions.

These functions calculate Bitcoin-specific indicators: base_tf_btc_indicators tracks Bitcoin's long-term price trend, while info_tf_btc_indicators computes the 8-period RSI for momentum. Both functions rename columns with a btc_ prefix for easy identification in the data.

In this section the indicators are defined on which the trading algorithm is based. These indicators will be added to the dataframe and then be used in the buy and sell signals later. I will not go over this line by line and this is pretty self-explanatory too I think. So let’s continue with the buy and sell signals:

This populate_buy_trend function defines the logic for generating buy signals. It checks multiple conditions for buying, including whether the price is below certain moving averages, the RSI levels, and the EWO value. It adds signal tags to each buy condition like lambo2, buy1ewo, buy2ewo, and cofi depending on which conditions are met. 


An interesting thing is added at the end here. It negates buying opportunities during pump-and-dump warnings or when Bitcoin's RSI is too low, preventing risky trades.

So when these conditions are met, then before this function is finished, the buy signal 1 has been set to 0 again. Which prevents the actual buy. A pretty neat and clever trick that I cannot remember seeing earlier.

The sell settings have a similar pattern as the buy signals. Multiple conditions are set to generate a sell trigger so hopefully these will do the job of exiting without or with minimal losses. Because of the disabled stop-loss setting.

Now to finish this walkthrough. There is also a dca class that is derived from the original EI3 class above. But I will not test this in this video. But you are always welcome to do this yourself and if you want add your findings to the comments section below this video.

I want to start as quickly as possible with the backtests to see how this algo performs. 

So if you subscribe to this channel quickly , click the like button of this video and add a few random letters to the comments section like GRT, or THX, or even URGOAT then I can present you with the findings.

Backtest results

So after backtesting this strategy I got the following results back from the engine.

By the way I also tested this algo on possible lookahead bias, but the included command for finding this future snooping did not find any…

This strategy performs pretty well I must say. 

The 5 minute timeframe shows the most profitable results with a really optimistic 5935.60% profit and a high win rate of 95.54%. Despite the strong performance, the max drawdown of 47.84% is notable and indicates the strategy can experience significant losses during unfavorable conditions. The Calmar Ratio of 6.10 and Sharpe Ratio of 4.87 suggest a good balance between risk and return over this period, though risk management may need refinement given the drawdown. The given that 65 percent of my used pairs has a favorable response rate might suggest that other pairs can get good results with this algorithm too.

The equity curve shows that wins steadily increase over time, especially from mid-2020 through 2021, reflecting a consistent success rate. However after the 2021 bull market (marked by the yellow dashed line), wins continue to grow, but the profit curve begins to falter. This gives me the impression that divergence between growing wins and falling profits post-bull market might suggests that the profitability of trades decreases significantly in bearish or volatile conditions. 


The drawdown analysis shows significant peaks, exceeding 40% in both 2020 and 2021, particularly during volatile market periods. After the 2021 bull market, drawdowns increase in frequency and severity, indicating the strategy's struggle in less favorable conditions. The high average drawdown of 20.45% in this plot range suggests the need for better risk management in my opinion.

The left box plot shows that the winrate is tightly clustered around 95%, indicating consistent success in trades. But outliers exist below 80%, suggesting occasional weeks of poor performance, but these are rare.

The profit distribution shows more variability, with a median profit around 0 and outliers extending to both large gains (above 10,000) and significant losses (down to -20,000).

This highlights that while the strategy wins often, the magnitude of profits and losses can vary greatly, with some weeks experiencing substantial losses despite the high win rate.

So even when the strategy has a strong win rate, profit outcomes are highly variable, reflecting the risk of occasional large losses despite frequent successful trades.

The EI3v2_tag_cofi_green strategy leads in win percentage compared to other strategies, indicating strong winning performance. However, it has the highest drawdown, reflecting significant risk exposure. In addition to this, it also falls short on the profit factor. This suggests that it wins frequently but the size of its profits might not consistently outweigh significant occasional losses.

Nonetheless, these results are still some to be proud of and in this chart there are no strategies anymore that are flatliners in comparison with the best scoring algorithms.

And with these backtest results, this strategy ends up somewhere in the top 20 of best performing algorithms on backtests.

Ending

Now remember that a trading Idea and backtests results only show one half of the complete picture. The next thing you should do, if you are interested in exploring this algo further is to try to find out why it has bad performance under bearish market circumstances. 

But most of all a decent forward test under live market circumstances gives you the best information on the actual performance of a trading algorithm. For more information on that you can always see my previous video where I test some of the best algorithms found so far. These tests will show you some hard but honest and sobering evidence on the real performance of some of the best strategies.

For now, this is it. Thank you for being a Patron and see you in the next post.

Goodbye!!

Decoding the EI3v2_tag_cofi_green Strategy Decoding the EI3v2_tag_cofi_green Strategy

Comments

Yes, you are correct. I was also corrected by somebody on Youtube about this. It appears that FT is downloading at least 500 candles when it starts the bot. So in that case it can start immediately trading. So the theory is correct but in practice it worked out differently then I always thought. Thanks for your remark!

Dutch Algotrading

Hi. I don't understand the part with 400 candles and that the bot will take trades only after 400 x 5min candles (1.5 days), after the start (dry/live run). I did not find this in FQ documentation. And when you start the bot the current dataframe already has available (0-998/999) so aprox. last 1000 historical candles . So it can calculate from start indicators where last 400 candles are needed.

Mihai Dobrescu


More Creators