The CombinedBinHClucAndMADV6 strategy is a trading strategy implemented as a class that extends the IStrategy interface. It consists of two main functions: populate_indicators and populate_buy_trend, along with a populate_sell_trend function. In the populate_indicators function, various indicators are calculated and populated in the given dataframe.
These indicators are derived from different timeframes and are merged using the merge_informative_pair function.
The populate_buy_trend function determines the buy signals based on specific conditions.
There are multiple sections within this function that represent different strategies:
Strategy ClucMay72018:
Buy if the current close price is greater than the 200-day exponential moving average (ema_200). Buy if the current close price is greater than the 1-hour exponential moving average (ema_200_1h). Buy if the current close price is less than the slow exponential moving average (ema_slow). Buy if the current close price is less than 0.99 times the lower Bollinger Band (bb_lowerband). Buy if the volume over a slow period is greater than 40% of the volume 30 periods ago. Exclude buying if the volume is 0. Strategy ClucMay72018 (alternative conditions):
Buy if the current close price is less than the slow exponential moving average (ema_slow). Buy if the current close price is less than 0.975 times the lower Bollinger Band (bb_lowerband). Buy if the 1-hour relative strength index (rsi_1h) is less than 15. Buy if the volume over a slow period is greater than 40% of the volume 30 periods ago. Exclude buying if the volume is 0. Strategy MACD Low buy:
Buy if the current close price is greater than the 200-day exponential moving average (ema_200). Buy if the current close price is greater than the 1-hour exponential moving average (ema_200_1h). Buy if the 26-day exponential moving average (ema_26) is greater than the 12-day exponential moving average (ema_12). Buy if the difference between ema_26 and ema_12 is greater than 2% of the current open price. Buy if the difference between the shifted ema_26 and ema_12 is greater than 1% of the current open price. Buy if the volume is less than 4 times the volume of the previous period. Buy if the current close price is less than the lower Bollinger Band (bb_lowerband). Buy if the volume over a slow period is greater than 40% of the volume 30 periods ago. Exclude buying if the volume is 0. Strategy MACD Low buy (alternative conditions):
Buy if the 26-day exponential moving average (ema_26) is greater than the 12-day exponential moving average (ema_12). Buy if the difference between ema_26 and ema_12 is greater than 3% of the current open price. Buy if the difference between the shifted ema_26 and ema_12 is greater than 1% of the current open price. Buy if the volume is less than 4 times the volume of the previous period. Buy if the current close price is less than the lower Bollinger Band (bb_lowerband). Buy if the volume is greater than 0. Additional conditions:
Buy if the current close price is less than the 5-day simple moving average (sma_5). Buy if the SSL upper line on the 1-hour timeframe (ssl_up_1h) is greater than the SSL lower line on the 1-hour timeframe (ssl_down_1h). Buy if the slow exponential moving average (ema_slow) is greater than the 200-day exponential moving average (ema_200). Buy if the 1-hour exponential moving average (ema_50_1h) is greater than the 200-day exponential moving average (ema_200_1h). Buy if the relative strength index (rsi) is less than the 1-hour relative strength index (rsi_1h) minus 43.276. Buy if the volume is greater than 0. The function sets the "buy" column in the dataframe to 1 for the rows that satisfy the specified buy conditions. The populate_sell_trend function determines the sell signals based on a specific condition. If the current close price is greater than 1.01 times the middle Bollinger Band (bb_middleband) and the volume is greater than 0, the "sell" column in the dataframe is set to 1. Finally, the updated dataframe is returned by both the populate_buy_trend and populate_sell_trend functions.