The CombinedBinHClucAndMADV5 strategy is implemented as a class that inherits from the IStrategy class. It has two main functions: populate_indicators and populate_buy_trend, as well as a populate_sell_trend function. The populate_indicators function takes a DataFrame and a metadata dictionary as inputs and calculates various indicators based on the input data.
It merges the informative 1-hour indicators with the current timeframe indicators using the merge_informative_pair function.
The resulting DataFrame is then returned.
The populate_buy_trend function populates the "buy" column of the DataFrame based on specific conditions. It uses multiple strategies to determine when to buy. The first strategy, named "ClucMay72018," checks if the close price is above the 200-day exponential moving average (ema_200) and the 1-hour exponential moving average (ema_200_1h). Additionally, it verifies that the close price is below the "ema_slow" value, which is not explicitly defined in the given code. Furthermore, it checks if the close price is less than 99% of the lower Bollinger Band (bb_lowerband) and if the volume is less than 21 times the slow volume mean (volume_mean_slow). Finally, it confirms that the volume is greater than 0. The second strategy within populate_buy_trend also belongs to the "ClucMay72018" strategy. It checks if the close price is below the "ema_slow" value and less than 97.5% of the lower Bollinger Band (bb_lowerband). It also verifies that the volume is less than 20 times the slow volume mean and less than 4 times the previous volume. Additionally, it checks if the 1-hour relative strength index (rsi_1h) is less than 15 and if the volume is greater than 0. The third and fourth strategies are both referred to as "MACD Low buy." In the first one, it checks if the close price is above the 200-day exponential moving average (ema_200) and the 1-hour exponential moving average (ema_200_1h). It also verifies that the 26-day exponential moving average (ema_26) is greater than the 12-day exponential moving average (ema_12). Moreover, it checks if the difference between ema_26 and ema_12 is greater than 2% of the opening price and if the difference between the previous ema_26 and ema_12 is greater than 1% of the opening price. Additionally, it checks if the volume is less than 4 times the previous volume, if the close price is below the lower Bollinger Band, and if the volume is greater than 0. The second "MACD Low buy" strategy is similar to the previous one, but it uses a 3% threshold instead of 2% for the difference between ema_26 and ema_12. The fifth strategy within populate_buy_trend is not explicitly named. It checks if the close price is below the 5-day simple moving average (sma_5) and if the 1-hour SSL up value (ssl_up_1h) is greater than the 1-hour SSL down value (ssl_down_1h). Additionally, it verifies that the 50-day exponential moving average (ema_50) is greater than the 200-day exponential moving average (ema_200) and that the 50-day exponential moving average for the 1-hour timeframe (ema_50_1h) is greater than the 200-day exponential moving average for the 1-hour timeframe (ema_200_1h). It also checks if the relative strength index (rsi) is less than the 1-hour relative strength index (rsi_1h) minus a specific value (43.276) and if the volume is greater than 0. The populate_sell_trend function populates the "sell" column of the DataFrame based on a condition. It checks if the close price is greater than 101% of the middle Bollinger Band (bb_middleband) and if the volume is greater than 0. Overall, the CombinedBinHClucAndMADV5 strategy combines different buy conditions from multiple strategies and a single sell condition to generate trading signals.