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提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。