OPEN-SOURCE SCRIPT
מעודכן

Toreda Liquidity Flow

913
# Toreda Liquidity Flow

**Pivot-based liquidity mapping with sweep detection, bias gauge, and right-edge strength histogram.**

---

## What it does

Toreda Liquidity Flow detects untapped buy-side and sell-side liquidity from confirmed swing pivots, scores each level by your chosen strength metric (volume, age, or touches), and tracks when price sweeps through them. A side panel summarizes the current bias; a right-edge histogram aggregates the surviving liquidity by price band so you can see at a glance where the heaviest unswept inventory sits.

This is **liquidity-based analysis, not volume profile**. The histogram on the right plots summed pivot strength per price band — not traded volume. Use it alongside a volume profile if you want both views.

---

## How to read the chart

- **Green horizontal lines (buy-side)** — unswept lows below current price. Likely resting buy stops / support.
- **Red horizontal lines (sell-side)** — unswept highs above current price. Likely resting sell stops / resistance.
- **Number next to each line** — the level's strength score (volume at the pivot bar by default).
- **Right-edge horizontal bars (histogram)** — total strength in each price band. Longer bar = more liquidity stacked at that price. Color matches side (green below current close, red above).
- **Bias panel (top-right)** — BULLISH / BEARISH / NEUTRAL based on the imbalance between unswept buy-side and sell-side strength within your bias lookback window.
- **✕ marks** (optional) — where a level got swept; the line dims but stays visible for context.

Non-repainting: every level is confirmed `Pivot Lookback` bars *after* the swing forms.

---

## Settings

### Core
- **Pivot Lookback (Sensitivity)** — bars required each side to confirm a pivot. Higher = fewer, stronger swings.
- **Max Levels per Side** — caps the number of active levels per side; older ones get pruned.
- **Remove Swept Levels** — delete on breach (clean chart) or keep dimmed with a ✕ mark (full history).
- **Sweep Confirmation** — *Wick* (any trade-through) or *Close* (bar must close beyond the level).

### Strength
- **Strength Metric** — Volume (snapshot at the pivot bar), Age (bars since formation), or Touches (proximity hits).
- **Minimum Strength to Display** — hide weak levels.
- **Touch Distance (ATR multiple)** — how close price must get to count as a touch.

### Filters
- **Detect Only Within Session** — restrict new-level detection to a specific session window.

### Visuals
- Colors, transparency, line width, label size.
- **Extend Lines to Right Edge** — long ribbons across the chart vs. short segments at origin.
- **Show Liquidity Histogram (right edge)** — toggles the right-side strength bars.
- **Histogram Bands** — number of price bands the level range is split into (more = thinner bars).
- **Histogram Max Bar Width** — width of the strongest band in chart bars; everything else scales relative to it.

### Bias Panel
- **Bias Calc Lookback (bars)** — only levels formed within this window contribute to the bias score.
- **Bias Threshold (%)** — magnitude of net imbalance required to flip out of NEUTRAL.

### Alerts
- **New Liquidity Formed** — fires when a new pivot-derived level is confirmed.
- **Liquidity Swept** — fires when any level is breached.

---

## How the bias is calculated

```
biasPct = (sellWeight - buyWeight) / total * 100

> +threshold → BEARISH (resistance overhead dominates)
< -threshold → BULLISH (support below dominates)
else → NEUTRAL
```

Each unswept level contributes `max(strength, 1)` to its side's weight. Weighting by strength means a single high-volume pivot can outweigh several low-volume ones.

---

## Best timeframes and markets

- Designed for **intraday charts** (1m / 5m / 15m / 1h) on liquid instruments — futures (ES/NQ/MNQ), index ETFs, large-cap equities, major FX pairs.
- Higher timeframes work but produce fewer levels — bump `Pivot Lookback` down to compensate.
- Volume strength metric requires a market with reported volume. For symbols without volume (most spot FX), switch to **Age** or **Touches**.

---

## Limitations

- The histogram aggregates levels' price range, not the chart's visible range — if you zoom into a tight window, most bands will sit off-screen.
- Strength is captured at pivot formation, not continuously recomputed (except for Age, which updates each bar).
- Sweep detection is a single-bar check — wick mode can flag scratches; use Close mode for stricter confirmation.
- No higher-timeframe MTF aggregation — each instance is single-TF.

---

## Version

**v1.0** — Initial public release.
הערות שחרור
1. Fair Value Gaps (FVG)

- Detects the classic 3-bar imbalance pattern:
- Bullish FVG: low > high[2] — zone between high[2] (bottom)
and low (top), acts as support
- Bearish FVG: high < low[2] — zone between high (bottom) and
low[2] (top), acts as resistance
- Drawn as filled colored boxes that extend to the right edge of
the chart
- Configurable bullish/bearish colors

2. Inverse Fair Value Gaps (IFVG)

- When price closes fully through an FVG, it converts to an IFVG
(color flip):
- Bullish FVG broken downward → Bearish IFVG (former support
now acts as resistance)
- Bearish FVG broken upward → Bullish IFVG (former resistance
now acts as support)
- Toggleable via Convert Filled FVG → IFVG — if off, broken FVGs
are removed instead of converted
- Separate color inputs for bullish IFVG and bearish IFVG

3. Higher-Timeframe FVG/IFVG

- Optional detection on a user-selected HTF (default 60m)
- Uses request.security with lookahead_off → non-repainting
- Fires once per HTF bar close — no duplicates
- Independent toggle: Detect FVG on Higher TF

4. Lifecycle / Removal Logic

- FVG age cap: auto-pruned after N bars (default 200) to keep the
chart clean
- FVG min size filter: skip micro-gaps below X × ATR
- IFVG removal: an IFVG is removed the moment price returns to /
through the zone in any direction (zone is considered mitigated)
- No-IFVG mode: when toggle is off, FVG removed on first
close-through

5. Right-Edge Text Labels

- Plain-text label per active FVG/IFVG (no background, no arrow)
- Text colored to match the zone's color so direction is visually
obvious
- Positioned at bar_index + N (default +3) and repositioned every
last-bar update so they follow the latest candle and stay in
view
- HTF gaps prefix the timeframe: 60 FVG, 60 IFVG, etc. —
current-TF gaps stay as plain FVG / IFVG
- Toggleable + offset adjustable

6. Visual Tweaks

- Box borders set to border_width=0 (pure fill, no outline)
- Box transparency from color inputs (default ~70–75%)

Inputs Added (under new "Fair Value Gaps" group)

Input: Detect FVG on Current TF
Default: ON
Purpose: Chart-TF FVG detection
────────────────────────────────────────
Input: Detect FVG on Higher TF
Default: OFF
Purpose: HTF FVG detection
────────────────────────────────────────
Input: Higher TF for FVG
Default: 60
Purpose: HTF resolution string
────────────────────────────────────────
Input: Convert Filled FVG → IFVG
Default: ON
Purpose: FVG → IFVG flip vs. immediate removal
────────────────────────────────────────
Input: Min FVG Size (ATR multiple)
Default: 0.0
Purpose: Filter micro-gaps
────────────────────────────────────────
Input: Max FVG Age (bars)
Default: 200
Purpose: Auto-prune old zones
────────────────────────────────────────
Input: 4× FVG/IFVG color inputs
Default: (teal/red/blue/purple)
Purpose: Per-state coloring
────────────────────────────────────────
Input: Show FVG / IFVG text labels at right edge
Default: ON
Purpose: Label visibility toggle
────────────────────────────────────────
Input: Label Offset (bars right of latest)
Default: 3
Purpose: How far right labels sit

כתב ויתור

המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.