The BBRSI_Train strategy is a trading strategy that uses Bollinger Bands and RSI (Relative Strength Index) indicators to generate buy and sell signals. In the populate_indicators method, several indicators are added to the input DataFrame. These include:
RSI: Relative Strength Index calculated from the DataFrame's data.
Bollinger Bands are then calculated using the qtpylib.bollinger_bands function, with different standard deviation values (2, 1, and 3) and a window size of 20.
The resulting upper, middle, and lower bands are added to the DataFrame as follows:
bb_lowerband, bb_middleband, bb_upperband (stds=2)
bb_lowerband1, bb_middleband1, bb_upperband1 (stds=1)
bb_lowerband3, bb_middleband3, bb_upperband3 (stds=3)
The populate_buy_trend method populates the buy signal column in the DataFrame.
The buy signal is triggered when the closing price is below the bb_lowerband1. The populate_sell_trend method populates the sell signal column in the DataFrame. The sell signal is triggered when the closing price is above the bb_lowerband1. Overall, this strategy combines Bollinger Bands and RSI indicators to identify potential buying opportunities when the price is below the lower Bollinger Band and selling opportunities when the price is above the lower Bollinger Band.