Long/Short Ratio [BigBeluga]🔵 OVERVIEW
Long/Short Ratio is a lower-timeframe volume imbalance analyzer that estimates real-time buyer vs seller dominance inside each bar.
Instead of relying on exchange-reported positioning data, this indicator reconstructs directional pressure by aggregating volume from lower timeframes and separating it into buy-side and sell-side flow.
The result is a dynamic percentage-based long/short ratio that reflects immediate participation shifts and short-term positioning pressure.
🔵 CORE CONCEPT
Directional Volume Segmentation — Volume is classified as positive (buyers) when close > open, and negative (sellers) when close < open.
Lower-Timeframe Aggregation — The script pulls volume data from smaller internal timeframes and aggregates it into the current chart bar.
Buyer vs Seller Percentage — Total positive and negative volumes are converted into percentage ratios.
Momentum Shift Detection — A smoothed change of the ratio helps detect acceleration or deceleration in positioning pressure.
🔵 HOW IT WORKS
1️⃣ Lower-Timeframe Volume Sampling
The script automatically determines an internal lower timeframe based on the current chart timeframe.
Volume is requested using request.security_lower_tf() .
array delta_sign = request.security_lower_tf('', lower_tf, (close > open ? volume : -volume))
This allows intra-bar analysis instead of using only finalized candle volume.
2️⃣ Buyer / Seller Calculation
If close > open → volume counts as buyer pressure.
If close < open → volume counts as seller pressure.
Buyer and seller totals are accumulated separately.
Percentages are calculated:
Buy % = Buyers / Total Volume
Sell % = Sellers / Total Volume
3️⃣ Ratio Visualization
Long (Buy %) plotted as teal columns.
Short (Sell %) plotted as maroon columns.
50% midline represents balance between buyers and sellers.
A stepline tracks the Buy % ratio for clarity.
4️⃣ Smoothed Ratio Momentum
The indicator calculates a smoothed HMA of the user-defined change in Buy %.
This produces a momentum curve showing acceleration in dominance.
Color logic:
Teal → Increasing long pressure
Maroon → Increasing short pressure
A dynamic midline (average of recent values) provides equilibrium reference.
5️⃣ Main Chart Dashboard
A dedicated heads-up display (HUD) is anchored to the top-right of your main price chart (via force_overlay).
This table provides the exact real-time Buy/Sell percentages of the current candle at a glance.
Provides instant clarity without having to look down at the indicator pane.
6️⃣ Extreme Sentiment Signals
Visual plotshape icons appear directly on the main chart when sentiment hits user-defined extreme thresholds.
Extreme Buy: A triangle appears at the bottom of the price chart when buyers exceed the limit (default 80%).
Extreme Sell: A triangle appears at the top of the price chart when sellers exceed the limit (default 80%).
These markers help identify potential reversal points or "exhaustion" spikes.
🔵 KEY FEATURES
Lower-timeframe volume reconstruction.
Real-time Buy vs Sell percentage display.
Main chart dashboard for immediate data access.
Adjustable Extreme Sentiment markers and thresholds.
Customizable colors and smoothing periods for the momentum curve.
Clear 50% equilibrium reference line.
Dynamic long/short stepline.
Automatic timeframe adaptation.
Visual Buy / Sell labels with live percentage updates.
🔵 HOW TO USE
Above 50% Buy → Long pressure dominance.
Below 50% Buy → Short pressure dominance.
Watch for strong divergence between price and ratio.
Use the smoothed ratio curve to detect acceleration in positioning.
Extreme spikes (marked by triangles) can indicate exhaustion or breakout fuel.
Best used on 5-minute and higher timeframes for reliable aggregation.
🔵 INTERPRETING POSITIONING
Rising price + rising Buy % → Confirmed bullish participation.
Rising price + falling Buy % → Weak trend / potential divergence.
Falling price + rising Buy % → Absorption.
Extreme imbalance → Potential short squeeze or long squeeze setup.
🔵 CONCLUSION
Long/Short Ratio provides a clean, data-driven view of intrabar participation pressure without relying on external exchange positioning feeds.
By combining lower-timeframe aggregation, percentage imbalance, and smoothed momentum detection—now enhanced with a main chart dashboard and extreme signal icons—it offers a practical tool for spotting positioning shifts, divergence, and participation-driven breakouts.
Pine Script® indicator






















