PROTECTED SOURCE SCRIPT

YBL – Order Flow Bubbles + Alerts (Imbalance, Anchored)

30
**YBL – Order Flow Bubbles + Alerts (Imbalance, Anchored)**
by **YBL / Yuriel**

This tool paints **order flow “bubbles”** directly on the price chart whenever there is a strong **aggressive buy or sell imbalance**, using only OHLCV data (no real bid/ask feed required).

The script estimates delta from **price change × volume**, normalizes it with a **z-score**, and then draws visual bubbles on the candles where the imbalance is strong enough.

---

## 🔍 Core Logic (How It Works)

1. **Delta estimation (no bid/ask feed needed)**
- `delta = (close - open) * volume`
- If price closes above open → delta > 0 (buy aggression).
- If price closes below open → delta < 0 (sell aggression).

2. **Volatility / Z-score filter**
- Moving averages over **lenDelta**:
- `avgVol = SMA(volume)`
- `avgDelta = SMA(delta)`
- `stDelta = stdev(delta)`
- Z-score:
- `deltaZ = (delta - avgDelta) / stDelta`
- Only bars where:
- Volume is above `minVolMul × avgVol`
- |deltaZ| is above `zTrigger`
are considered **strong aggression bubbles**.

3. **Direction detection**
- **Buy bubble** = `delta > 0` with strong z-score and enough volume.
- **Sell bubble** = `delta < 0` with strong z-score and enough volume.

---

## 🎨 Visuals on the Chart

- **Bubbles (labels)**
- Green bubbles for **buy aggression**.
- Red bubbles for **sell aggression**.
- Bubble **size is dynamic** → based on `vol / avgVol`:
- Tiny / Small / Normal / Large / Huge depending on the volume ratio.
- Text inside the bubble (optional):
- Shows `Δ` in **K units** (e.g. `+35.2K`).
- Controlled by `Mostrar Δ (K) dentro de la burbuja`.

- **Anchoring options**
- `Anclaje de burbuja`:
- **“Extremos (Hi/Lo)”** →
- Buy bubbles anchored near **low + ATR offset**.
- Sell bubbles anchored near **high − ATR offset**.
- **“Centro (Mid)”** →
- Bubbles at the **midpoint** of the candle.
- ATR offset is defined by:
- `ATR para offset` (atrLen)
- `Offset = ATR ×` (atrMul)

- **Background shading (heatmap)**
- When a very strong **buy imbalance** appears → chart background tinted **light lime**.
- When a very strong **sell imbalance** appears → background tinted **light red**.
- Helps visually detect clusters of aggressive buying or selling.

- **Tooltips**
- Each bubble includes a tooltip with:
- `Δ` (raw delta)
- `z` (z-score of delta)
- % of volume vs average (Vol%)

---

## ⚙️ Inputs (Settings Overview)

### Group “Cálculo”
- **Longitud media/volatilidad (z-score)** (`lenDelta`)
Lookback for average volume, delta and standard deviation.
- **Umbral z-score desequilibrio fuerte** (`zTrigger`)
Higher = fewer but stronger signals.
- **Volumen mínimo (× promedio)** (`minVolMul`)
Minimum volume relative to average volume.

### Group “Dibujo”
- **Transparencia burbujas (0=opaco)**
Controls how strong the color of the bubbles is.
- **Mostrar Δ (K) dentro de la burbuja**
Toggle on/off the text inside the bubbles.
- **Tamaño del TEXTO**
tiny / small / normal / large / huge.
- **Anclaje de burbuja**
- “Extremos (Hi/Lo)” → buy near low, sell near high.
- “Centro (Mid)” → bubble in the middle of the bar.
- **ATR para offset** / **Offset = ATR ×**
Fine-tune vertical offset relative to high/low.

---

## 📢 Alerts

The script includes ready-to-use **alerts**:

1. **BUY Aggression Bubble**
- Triggered when a strong **buy imbalance** appears (green bubble).
- Message includes ticker, timeframe and close.

2. **SELL Aggression Bubble**
- Triggered when a strong **sell imbalance** appears (red bubble).
- Message includes ticker, timeframe and close.

Use these alerts to catch:
- Sudden bursts of **aggressive buying** at lows or pullbacks.
- Sudden bursts of **aggressive selling** at highs or after rallies.
- Potential **reversal** or **continuation** points based on flow.

---

## 🧠 How to Use (Practical Ideas)

- Combine this script with:
- **VWAP**, volume profile, liquidity pools or CVD.
- Your own session filters (e.g. NY open, London open).
- Look for:
- **Clusters of green bubbles** at support / VWAP → potential accumulation.
- **Clusters of red bubbles** at resistance / previous highs → possible distribution.
- Breakouts where the candle is supported by **large same-direction bubbles**.

It works especially well on:
- **1m / 5m** charts for scalping and intraday.
- Futures, indices, FX and crypto where volume is reliable.

---

## ⚠️ Disclaimer

This script is for **educational purposes only** and does **not** constitute financial advice.
Always backtest and use proper risk management before trading live.

---

© YBL / Yuriel – “YBL – Order Flow Bubbles + Alerts (Imbalance, Anchored)”
If you find this useful, please **leave a like ⭐ and add it to your favorites.**

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.