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.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。