OPEN-SOURCE SCRIPT
Cập nhật

Ralis Bull/Bear Oscillator

578
Ralis Bull/Bear Oscillator measures buying and selling pressure using True Range decomposition. Unlike single-bar OHLC analysis, True Range captures gap pressure from the prior close, giving a more complete picture of who controlled the bar. Buying pressure is the distance from the close to the true low (how far buyers pushed up), selling pressure is the distance from the true high to the close (how far sellers pushed down). Both are normalized by the true range to produce values on a 0–100 scale, then SMA-smoothed into two continuous lines: the green bull line and the red bear line.

The pressure engine offers three calculation modes. Intrabar mode normalizes each bar independently — pure micro reads of who won that specific bar. Structural mode sums buying pressure, selling pressure, and true range over a lookback window before normalizing — this reveals the cumulative balance of power over the period. Average mode blends both, giving you micro responsiveness anchored by macro context. The default Period of 10 and Smoothing Length of 10 work well across most assets and timeframes.

The 4-SMMA ribbon regime (8/16/24/32 on HL2) runs in the background, classifying the macro trend as Bullish, Bearish, or Neutral. Two independent tests must pass for a confirmed regime. Tangle detection checks that the inner ribbon lines (16/24) agree with the outer line relationship — if any inner line disagrees, the ribbon is tangled and the regime is Neutral. The neutral zone filter requires the percentage gradient between the fast outer (8) and slow outer (32) to exceed ±0.34% before confirming a trend. If the spread is too narrow, the regime stays Neutral regardless of alignment. The regime is displayed in the info table and can optionally tint the pressure lines. The SMMA calculations use inline var-state seeding for consistent cross-asset behavior.

Pressure divergence detects exhaustion by comparing pivots on the pressure ratio (bull / (bull + bear) as a percentage) against price. Bearish divergence fires when price makes a higher high but the pressure ratio makes a lower high — buying pressure is fading despite higher prices. Bullish divergence fires when price makes a lower low but the pressure ratio makes a higher low — selling pressure is weakening despite lower prices. Pivots use 5 bars left and 3 bars right by default, with a maximum 24-bar lookback between two pivots to qualify. Divergence markers are orange triangles (bearish, top of pane) and cyan triangles (bullish, bottom of pane), plotted at the pivot bar where the divergence was confirmed.

The spread histogram plots the difference between the bull and bear lines as columns behind the pressure lines. Green columns above zero indicate bull dominance, red columns below zero indicate bear dominance. Acceleration dimming modulates brightness based on whether the spread is growing or shrinking in magnitude. Bright bars mean the dominant side is gaining steam — the absolute spread is larger than the prior bar. Dim bars mean the dominant side is fading — the spread is contracting even though it may still be positive or negative. This gives an instant visual read on momentum acceleration without adding another indicator.

Regime-tinted lines optionally fade the pressure line that is fighting the current ribbon regime. In a bullish regime, the bear line dims to 60% transparency while the bull line stays full brightness. In a bearish regime, the bull line dims. In a neutral regime, both lines fade to 40% transparency. This helps the eye focus on the pressure line that matters given the macro context.

Percentile extreme bands draw the 90th and 10th percentile of both the bull and bear lines over a configurable lookback (default 200 bars). When either pressure line exceeds its 90th percentile, a subtle background highlight appears behind the oscillator pane — green for extreme buying pressure, red for extreme selling pressure. These zones flag historically unusual pressure readings that often precede reversals or signal trend acceleration.

The info table displays Pressure (BULLS or BEARS with color-coded background), the current bull and bear line values, the spread between them, the pressure ratio as a percentage (green above 55%, red below 45%, white in between), and the ribbon regime (BULLISH in gold, BEARISH in blue, NEUTRAL in gray). The table supports 9-position placement.

Four alert conditions are available. Bull Cross fires when buying pressure crosses above selling pressure. Bear Cross fires when selling pressure crosses above. Bull Divergence fires on bullish pressure divergence (price lower low, ratio higher low). Bear Divergence fires on bearish pressure divergence (price higher high, ratio lower high). All alerts include ticker and timeframe context.

Settings are organized into five groups. Pressure Engine controls the calculation period, mode (Average/Intrabar/Structural), and smoothing length. Ribbon Regime controls the 4-SMMA source, lengths, and neutral zone percentage. Divergence controls visibility, pivot left/right bars, and maximum lookback between pivots. Visual controls line colors, spread histogram toggle, regime-tinted lines toggle, and percentile extreme bands with their lookback length. Table controls visibility and 9-position placement.
Phát hành các Ghi chú
cosmetic

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.