The BinHV45 strategy is a backtesting strategy that uses Bollinger Bands to identify potential buying opportunities. Here's a breakdown of what the strategy does:
It calculates the Bollinger Bands using the rolling mean and standard deviation of the closing prices of a stock, with a window size of 40 and 2 standard deviations. It adds several additional indicators to the dataframe:
'mid': The middle band of the Bollinger Bands.
'lower': The lower band of the Bollinger Bands.
'bbdelta': The absolute difference between the middle and lower bands.
'pricedelta': The absolute difference between the opening and closing prices. 'closedelta': The absolute difference between the current and previous closing prices. 'tail': The absolute difference between the closing price and the lowest price. In the populate_buy_trend method, it identifies potential buying opportunities based on the following conditions:
The previous lower band is greater than 0. The 'bbdelta' is greater than 0.8% of the closing price. The 'closedelta' is greater than 1.75% of the closing price. The 'tail' is less than 25% of the 'bbdelta'. The closing price is lower than the previous lower band. The closing price is less than or equal to the previous closing price. When all these conditions are met, a 'buy' signal is generated in the dataframe. In the populate_sell_trend method, no sell signals are generated. The 'sell' column in the dataframe is set to 0. The strategy aims to generate a minimal return on investment (ROI) of 1.25% ('0': 0.0125) and has a stop loss of -5% (-0.05). It operates on a timeframe of 1 minute ('1m').