Key Concepts in the Script: RSI Calculation: The RSI is calculated with the user-defined period (rsiLength). The script uses the default 14-period RSI but you can adjust it. Bullish Divergence: Price Low: The script checks for the lowest price over the last 20 bars (ta.lowest(close, 20)). RSI Low: The script checks for the lowest RSI over the same 20 bars. Divergence Condition: Bullish divergence is identified when the price forms a lower low (priceLow1 < priceLow2), while the RSI forms a higher low (rsiLow1 > rsiLow2), and the RSI is below the oversold level (typically 30). Bullish Candle Pattern: A Bullish Engulfing pattern is defined as the current candle closing higher than it opened, and the close being above the previous candle's high. A Hammer pattern is defined as a candlestick where the close is higher than the open, and the low is the lowest of the last 5 bars. Buy Signal: The script generates a buy signal when both the bullish divergence and bullish candle are confirmed at the same time.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.