Gettig rich with Alligators? Post and files! (Patreon)
Downloads
Missing 1 file, as this post has not yet been imported.
Content
The Bill Williams trading strategy uses three moving averages with a offset and is mainly used to detect trends in prices.
In this post I will test 3 alligator type strategies. 2 Two of them I have found on Github and the third one I created myself with a custom made Bill Williams Alligator indicator. Here we will find out if the Alligator strategy can be used for Crypto trading and which one of these three has the highest probability to make money with trading.
Comparison
The original Bill Williams Alligator trading indicator uses three simple moving averages. The 5 SMA, 8 SMA and 13 SMA. Each representing a Finobacci number.
Each of these moving averages is also smoothed or skewed to the future with respectively 3, 5 and 8 to give it it's characteristic Alligator mouth.
Bill Williams also gave each moving average a specific name that refers to the process when an Alligator opening its mouth to catch a prey.
The SMA 5 are the lips, that open the first when the alligator starts to open it's mouth'. The SMA 8 are the teeth that are shown and will then open. And finally the SMA 13 is called the jaw, which opens the last.
The strategies I found on Github are somewhat based on these principles but have their own specific twist on this strategy.
The strategy and indicator I created will follow the Bill Williams strategy as closely as follows to test out how this would perform on the crypto market.
Let's compare them side by side.
Alligator strategy by Gert Wohlgemuth
The first Alligator strategy I found is created by a familiar algo creator: "Gert Wohlgemuth"
If you search this strategy on Github, you will find numerous locations that contain this file. So I will not point to specific location but you can search for this strategy yourself on Github.
Alligator strategy by Crypto robot
The second Alligator strategy was based a strategy on Cryptorobot's Github site, that site also contains a Jupyter notebook with some explanations and it even has a Youtube video about this algo. So watch that video for more detailed information on this strategy.
The code for using with the Freqtrade bot is also available on github in many repositories. So you can search for it yourself and use it for your trading.
Bill Williams Alligator strategy
By ChatGPT
The last Alligator version is based on the description that is given on Investopedia and is partially created with the help of ChatGPT.
I created a separate Python module for this and other rare indicators. This module does not only contain the Alligator indicator, but does also contain some other custom indicators that I created in my last couple of videos and posts. This way I can provide the community with all the indicators in a way thay can implement them in their own trading strategy.
Take note that this module it in it's early stages and does only contain a handfull of indicators and has no helpfile or other instructions yet. So please be carefull using this in a production environment.
You can get this module by using pip install bamboo-ta.
Strategy comparisons
Now for a quick comparison between these strategies. Which are all Spot trading strategy types. In other words, they only do long trades.
The default settings for the tested strategies are as follows:
Timeframe:
AlligatorStrat:
ticker_interval = '4h'AlligatorStrategy:
timeframe = '1h'Williams Alligator:
timeframe = "1d"ROI:
AlligatorStrat:
"0": 0.1AlligatorStrategy:
"0": 100 # inactiveWilliams Alligator:
minimal_roi = {"0": 10.0}Stop loss:
AlligatorStrat:
stoploss = -0.2AlligatorStrategy:
stoploss = -0.99 # inactivWilliams Alligator:
stoploss = -1.0Used indicators:
AlligatorStrat:
dataframe['SMAShort'] = ta.SMA(dataframe, timeperiod=5)
dataframe['SMAMedium'] = ta.SMA(dataframe, timeperiod=8)
dataframe['SMALong'] = ta.SMA(dataframe, timeperiod=13)
macd = ta.MACD(dataframe)
dataframe['macd'] = macd['macd']
dataframe['macdsignal'] = macd['macdsignal']
dataframe['macdhist'] = macd['macdhist']AlligatorStrategy:
buy_stoch_rsi = DecimalParameter(0.5, 1, decimals=3, default=0.82, space="buy")
sell_stoch_rsi = DecimalParameter(0, 0.5, decimals=3, default=0.2, space="sell")
dataframe['stoch_rsi'] = ta.momentum.stochrsi(close=dataframe['close'], window=14, smooth1=3, smooth2=3)
dataframe['ema7']=ta.trend.ema_indicator(close=dataframe['close'], window=7)
dataframe['ema30']=ta.trend.ema_indicator(close=dataframe['close'], window=30)
dataframe['ema50']=ta.trend.ema_indicator(close=dataframe['close'], window=50)
dataframe['ema100']=ta.trend.ema_indicator(close=dataframe['close'], window=100)
dataframe['ema121']=ta.trend.ema_indicator(close=dataframe['close'], window=121)
dataframe['ema200']=ta.trend.ema_indicator(close=dataframe['close'], window=200)Williams Alligator:
alligator_result = bta.AlligatorBands(
dataframe, "high", 13, 8, 5, jaw_shift=8, teeth_shift=5, lips_shift=3)
dataframe['jaw'] = alligator_result['jaw']
dataframe['teeth'] = alligator_result['teeth']
dataframe['lips'] = alligator_result['lips']Buy rules:
AlligatorStrat:
qtpylib.crossed_above(dataframe['SMAShort'], dataframe['SMAMedium']) &
((dataframe['macd'] > -0.00001)) &
(dataframe['macd'] > dataframe['macdsignal'])AlligatorStrategy:
(dataframe['ema7'] > dataframe['ema30']) &
(dataframe['ema30'] > dataframe['ema50']) &
(dataframe['ema50'] > dataframe['ema100']) &
(dataframe['ema100'] > dataframe['ema121']) &
(dataframe['ema121'] > dataframe['ema200']) &
(dataframe['stoch_rsi'] < self.buy_stoch_rsi.value) &
(dataframe['volume'] > 0)Williams Alligator:
(dataframe['jaw'] < dataframe['teeth']) &
(dataframe['teeth'] < dataframe['lips']) &
(dataframe['lips'] > dataframe['lips'].shift(1)) &
(dataframe['close'] > dataframe['lips'])
& (dataframe["volume"] > 0) # GuardSell rules:
AlligatorStrat:
((dataframe['close'] < dataframe['SMAMedium']) &
(dataframe['macd'] < dataframe['macdsignal'])AlligatorStrategy:
(dataframe['ema121'] > dataframe['ema7']) &
(dataframe['stoch_rsi'] > self.sell_stoch_rsi.value) &
(dataframe['volume'] > 0)Williams Alligator:
(dataframe['jaw'] > dataframe['teeth']) &
(dataframe['teeth'] > dataframe['lips']) &
(dataframe['lips'] < dataframe['lips'].shift(1)) &
(dataframe['close'] < dataframe['lips'])
& (dataframe["volume"] > 0) # GuardAlligatorStrat
AlligatorStrategy
Williams Alligator
Backtesting results
Ofcourse I backtested these according to my standardized way so that I can compare the results of these trading algoritmhs with the ones I tested earlier.
The results are as follows:
Alligatorstrat by Gert Wohlgemuth
This Alligator strategy has a moderate end score of 132. Mainly because it's low profits and low Calmar, Sortino and Sharpe ratio's. Personally I think that the winrate is pretty high and the drawdown moderately low, which is good.
The main reason this strategy scores this way is that the initially configured ROI makes most of the profits. The exit signal of the alligator indicators cause the most losses here. Maybe if I configured this algorithm to let it's winners run instead of taking profits, it would score much better.
Finally, I really like the way the profits are distributed accross the different pairs. No pumps caught but nice honest inclines, or sometimes declines.
And as with most tested strategies, the biggest drawdown period starts at the height of the last bull market when it turned into a bear market.
Alligator strategy by Crypto Robot
The Crypto Robot Alligator version does a much better job at catching big trendwaves. The ratio scores are much better, but as you can see from the win percentage and drawdown, this strategy version on this 30 minute timeframe suffers the same fate as with many other trend trading strategies. Low win rates, high losing streaks and high drawdowns.
Since the ROI has been disabled by using an insane high win percentage amount, the only exit signal comes from the configured indicators here. And as you can see, it has a high loss percentag, but if it catches bullish moves, it rides them out until the very end, so it seems.
This also can be seen on the profits plot. Here also the GALA/USDT pair was caught in a major bullish wave and it made a lot of profits there. As written in earlier posts, this is not guaranteed to happen in the future so you have to take these anomalies into consideration when you choose to use this strategy.
The other graphs speak for themselves and I will not discuss them here.
Bill Williams Alligator strategy
The Bill Williams trading strategy that I created with the help of ChatGPT has a performance that lies in between of the other Alligator algos I just discussed.
The 4 hour timeframe catches just enough trades to make it very profitable, but at the same time it suffers from a low winrate and high drawdown. The 1 day timeframe looks to perform better, but since this timeframe has an even lower Sortino, Sharpe ratio and Pairs ratio, it scores slightly less high. Making it a close second.
In this algo I also tried to disable the ROI, but apparently not high enough because it still caught 1 trade with 100 percent win. The other exit signals are caused by the reversed Alligator indicator signal settings.
Maybe if I tweaked something here that did not make it exactly the opposite as the buy signal, it would perform better.
Funny enough, this Alligator version is a more active in trading then the other two versions. But it still has its peak at the last bull market. It also caught the GALA pump here, so be aware that these occurrences are rare and might not happen in the future. The average drawdown is between 42 and 72 percent here. So take that into consideration as well when using this Alligator strategy version.
Optimizing the Alligator of Crypto Robot
Since the Crypto robot version performed the best, I also optimized this version to see how much profit I could squeeze out of it's performance. Luckily it is also the only file that has buy and sell optimization parameters on the stochastic RSI.
After this optimization I got the following results:
The optimization only changed the stochastics RSI buy and sell level and after a backtest with only these changed levels I got the following results back.
The changes are marginally but still it improved the effectivity of the strategy. The drawdown improved with 7 percent and the CAGR, Sharpe, Sortino and Calmar ratios improved as well. The winrate did not improve, but the amount of losers in a streak and the average losing streak did slightly.
The average profit percentage also improved with 15 points and together with the same win percentage it improved the hypothetical cumulative profit by a lot.
Again, no ROI and Stop loss exits since these were set at insane levels that probably would never be hit. Leaving the exit signals to the strategies indicator exit settings.
Now finally the profit plot that you get as a result of the backtest. Comparing this with the previous plot, there's not much special to say here. The bot is active in trading and catches some nice pumps, of which I already told you the downside of this.
Strategy League and conclusion
The basic rules of the Alligator trading strategy are very simple. Mostly because it uses very simple indicators and trading rules.
It also provides a lot of trading signals to follow and some of these signals can provide a trader with great wealth.
However, one of the greatest drawbacks of this trend following strategy is that it can also generate a lot of false signals during market circumstances that are moving sideways. You'll have to realise that 70 percent of your trade signals will be false and can cause many losses. The 30 percent that do make you money will do it really well.
In backtesting theory that is ofcourse!
Changing the rules of the strategy, like making them simpler or more complex, to fit certain market circumstances more, could lead to lesser but better signals. Adding additional indicators or specific trading rules like using support and resistance level breakthroughs could also make this strategy more effective.
However that is for you to decide how to alter this algorithm for your own benefit. At this moment I can conclude that the Alligator strategy certainly has potential as a baseline for your trading algorithm.
Strategy League
At the moment the Crypto Robot version of the Alligator strategy, using multiple EMA's takes it's place at the 13th position on the strategy league. Which is a fine position for such a simple trend following spot trading strategy.
Also since I move stuff to Patreon from that dutchalgotrading.com site, I am also looking for a sustainable way to publish this League. However Patreon Is not the best platform for this I noticed. So stay tuned for more news about this movement.
Ending and thanks
And with this knowledge I've come to the end of this post.
My eternal thanks for being a Patron!
The personal indicator library for Python is avaliable on Pypi, but it's still in it's early development stage. So use this at your own risk. You can try it out here: https://pypi.org/project/bamboo-ta/
Goodbye!!