The strategy implemented in this code is called "CombinedBinHAndCluc." It combines two sub-strategies, namely "BinHV45" and "ClucMay72018," to determine buying and selling signals for trading. The strategy uses Bollinger Bands as one of its indicators. Bollinger Bands consist of a moving average line (mid) and an upper and lower band that represent a certain number of standard deviations (num_of_std) away from the moving average.
The strategy calculates the lower band and the difference (bbdelta) between the mid and the lower band for the "BinHV45" sub-strategy.
For the "ClucMay72018" sub-strategy, the strategy calculates the lower band (bb_lowerband), the middle band (bb_middleband), the exponential moving average (ema_slow), and the 30-period rolling average of volume (volume_mean_slow).
To generate buy signals, the strategy applies specific conditions for each sub-strategy. For the "BinHV45" sub-strategy, it checks if the lower band from the previous time period is greater than zero, if bbdelta (mid - lower band) is greater than a certain threshold, if closedelta (difference between current close price and previous close price) is greater than a certain threshold, if the tail (difference between current close price and lowest price) is less than 25% of bbdelta, if the current close price is lower than the previous lower band, and if the current close price is less than or equal to the previous close price. For the "ClucMay72018" sub-strategy, it checks if the current close price is below the exponential moving average (ema_slow), if the current close price is below 98.5% of the previous lower band (bb_lowerband), and if the current volume is less than 20 times the previous 30-period rolling average of volume (volume_mean_slow). The strategy generates a "buy" signal (assigned as 1) when any of the conditions for either sub-strategy are met. To generate sell signals, the strategy checks if the current close price is above the middle band (bb_middleband) of the Bollinger Bands and assigns a "sell" signal (assigned as 1) when this condition is met. Overall, the strategy aims to identify potential buying opportunities based on the combined signals from the two sub-strategies and sells when the current close price exceeds the middle band of the Bollinger Bands.