The RSIDivTirail strategy is a trading strategy that uses the RSI (Relative Strength Index) indicator to identify divergence patterns in the price movement of a financial instrument. Here is a breakdown of what the strategy does:
In the populate_indicators function:
The RSI period is set to 14. The RSI is calculated based on the closing prices of the instrument.
Lookback periods (lbR and lbL) are set to 10 and 5, respectively.
The maximum and minimum lookback range values are set to 60 and 5, respectively.
Bullish and bearish plot settings are defined. The RSI values are calculated and stored in the 'osc' column of the dataframe. Pivot points (min and max) are calculated based on the RSI values. The 'plFound' and 'phFound' columns are used to mark the presence of pivot points. Conditions for bullish and hidden bullish divergence are checked based on the RSI and price movement. Conditions for bearish and hidden bearish divergence are checked based on the RSI and price movement. In the populate_buy_trend function:
Conditions for entering a buy trade are checked based on the presence of bullish and hidden bullish divergence patterns and positive volume. In the populate_sell_trend function:
Conditions for entering a sell trade are checked based on the presence of bearish and hidden bearish divergence patterns and positive volume. The strategy uses the RSI indicator and divergence patterns to generate buy and sell signals. It considers both regular and hidden divergence and incorporates volume as a filter for trade entry.