OPEN-SOURCE SCRIPT
BULL-BEAR-WALLDEM

Purpose and Overview
Designed for minimalistic charting, this indicator computes RSI (default 14-period on close) but hides all visuals—plots, bands, fills, and smoothing—to focus solely on divergence signals. With overlay=true, it integrates labels onto the main price chart, eliminating separate panes and scale issues. Divergences highlight momentum-price mismatches: bullish for potential upturns (e.g., weakening downtrends), bearish for downturns (e.g., fading rallies). The calculateDivergence input (default false) gates the logic, optimizing for user control and performance.
Technical Implementation
RSI Core: Employs ta.change(), ta.rma() for up/down averages, yielding rsi = 100 - (100 / (1 + up / down)).
Divergence Module: Uses ta.pivotlow()/ta.pivothigh() with fixed lookbacks (left/right: 5) and range filter (5-60 bars). Conditions: Bullish (rsiHL && priceLL), Bearish (rsiLH && priceHH), evaluated conditionally.
Rendering: plotshape() for labels (" Bull "/ " Bear ") at bar extremes (location.belowbar/abovebar), offset by -lookbackRight. Colors: green bull, red bear.
Hiding: color=na for plots/hlines; transparent color.new(..., 100) for fills. Smoothing via switch (SMA/EMA/etc.) but invisible.
Alerts: alertcondition() with pivot context messages.
The structure prioritizes readability: grouped inputs, modular functions, and no unnecessary visuals.
Usage Scenarios and Tips
Apply to trending markets—e.g., 4H BTCUSD for crypto reversals or daily TSLA for stock pullbacks. Enable divergence in settings; labels offset to pivots aid quick scans. Pair with volume or trends for confirmation; alerts enable real-time monitoring. For backtesting, adapt to strategy() using conditions as entry signals.
Customization Options
Inputs: RSI length (min 1), source, divergence toggle (hidden display).
Smoothing: Hidden group with MA types, lengths, BB multipliers.
Extensions: Expose lookbacks as input.int(); add hidden divergences or MTF via request.security().
Limitations and Considerations
Signals rely on data: No divergences mean no labels; adjust parameters for sensitivity.
Repainting possible on live bars; best on closed data.
Not standalone: Divergences (55-65% historical accuracy per studies) need context to avoid false positives in strong trends.
v6-dependent; compatible but feature-limited in v5.
Designed for minimalistic charting, this indicator computes RSI (default 14-period on close) but hides all visuals—plots, bands, fills, and smoothing—to focus solely on divergence signals. With overlay=true, it integrates labels onto the main price chart, eliminating separate panes and scale issues. Divergences highlight momentum-price mismatches: bullish for potential upturns (e.g., weakening downtrends), bearish for downturns (e.g., fading rallies). The calculateDivergence input (default false) gates the logic, optimizing for user control and performance.
Technical Implementation
RSI Core: Employs ta.change(), ta.rma() for up/down averages, yielding rsi = 100 - (100 / (1 + up / down)).
Divergence Module: Uses ta.pivotlow()/ta.pivothigh() with fixed lookbacks (left/right: 5) and range filter (5-60 bars). Conditions: Bullish (rsiHL && priceLL), Bearish (rsiLH && priceHH), evaluated conditionally.
Rendering: plotshape() for labels (" Bull "/ " Bear ") at bar extremes (location.belowbar/abovebar), offset by -lookbackRight. Colors: green bull, red bear.
Hiding: color=na for plots/hlines; transparent color.new(..., 100) for fills. Smoothing via switch (SMA/EMA/etc.) but invisible.
Alerts: alertcondition() with pivot context messages.
The structure prioritizes readability: grouped inputs, modular functions, and no unnecessary visuals.
Usage Scenarios and Tips
Apply to trending markets—e.g., 4H BTCUSD for crypto reversals or daily TSLA for stock pullbacks. Enable divergence in settings; labels offset to pivots aid quick scans. Pair with volume or trends for confirmation; alerts enable real-time monitoring. For backtesting, adapt to strategy() using conditions as entry signals.
Customization Options
Inputs: RSI length (min 1), source, divergence toggle (hidden display).
Smoothing: Hidden group with MA types, lengths, BB multipliers.
Extensions: Expose lookbacks as input.int(); add hidden divergences or MTF via request.security().
Limitations and Considerations
Signals rely on data: No divergences mean no labels; adjust parameters for sensitivity.
Repainting possible on live bars; best on closed data.
Not standalone: Divergences (55-65% historical accuracy per studies) need context to avoid false positives in strong trends.
v6-dependent; compatible but feature-limited in v5.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
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.