OPEN-SOURCE SCRIPT

Market Imbalance Tracker (Inefficient Candle + FVG)

204
# 📊 Overview

This indicator combines two imbalance concepts:

• **Squared Up Points (SUP)** – midpoints of large, "inefficient" candles that often attract price back.
• **Fair Value Gaps (FVG)** – 3-candle gaps created by strong impulse moves that often get "filled."

Use them separately or together. Confluence between a SUP line and an FVG boundary/midpoint is high-value.

---

# ⚡ Quick Start (2 minutes)

1. **Add to chart** → keep defaults (Percentile method, 80th percentile, 100-bar lookback).
2. **Watch** for dashed SUP lines to print after large candles.
3. **Toggle Show FVG** → see green/red boxes where gaps exist.
4. **Turn on alerts** → New SUP created, SUP touched, New FVG.
5. **Trade the reaction** → look for confluence (SUP + FVG + S/R), then manage risk.

---

# 🛠 Features

## 🔹 Squared Up Points (SUP)

• **Purpose:** Midpoint of a large candle → potential support/resistance magnet.
• **Detection:** Choose *Percentile* (adaptive) or *ATR Multiple* (absolute).
• **Validation:** Only plots if the preceding candle does not touch the midpoint (with tolerance).
• **Lifecycle:** Line auto-extends into the future; it's removed when touched or aged out.
• **Visual:** Horizontal dashed line (color/width configurable; style fixed to dashed if not exposed).

## 🔹 Fair Value Gaps (FVG)

• **Purpose:** 3-candle gaps from an impulse; price often revisits to "fill."
• **Detection:** Requires a strong directional candle (Marubozu threshold) creating a gap.
• **Types:**
- **Bullish FVG (Green):** Gap below; expectation is downward fill.
- **Bearish FVG (Red):** Gap above; expectation is upward fill.
• **Close Rules (if implemented):**
- *Full Fill:* Gap closes when the opposite boundary is tagged.
- *Midpoint Fill:* Gap closes when its midpoint is tagged.
• **Visual:** Colored boxes; optional split-coloring to emphasize the midpoint.

> **Note:** If a listed FVG option isn't visible in Inputs, you're on a lighter build; use the available switches.

---

# ⚙️ Settings

## SUP Settings

• **Candle Size Method:** Percentile (top X% of recent ranges) or ATR Multiple.
• **Candle Size Percentile:** e.g., 80 → top 20% largest candles.
• **ATR Multiple & Period:** e.g., 1.5 × ATR(14).
• **Percentile Lookback:** Bars used to compute percentile.
• **Lookback Period:** How long SUP lines remain eligible before auto-cleanup.
• **Touch Tolerance (%):** Buffer based on the inefficient candle's range (0% = exact touch).

## Line Appearance

• **Line Color / Width:** Customizable.
• **Style:** Dashed (fixed unless you expose a style input).

## FVG Settings (if present in your build)

• **Show FVG:** On/Off.
• **Close Method:** Full Fill or Midpoint.
• **Marubozu Wick Tolerance:** Max wick % of the impulse bar.
• **Use Split Coloring:** Two-tone box halves around midpoint.
• **Colors:** Bullish/Bearish, and upper/lower halves (if split).
• **Max FVG Age:** Auto-remove older gaps.

---

# 📈 How to Use

## Trading Applications

• **SUP Lines:** Expect reaction on first touch; use as S/R or profit-taking magnets.
• **FVG Fills:** Price frequently tags the midpoint/boundary before continuing.
• **Confluence:** SUP at an FVG midpoint/boundary + higher-timeframe S/R = higher quality.
• **Bias:** Clusters of unfilled FVGs can hint at path of least resistance.

## Best Practices

• **Timeframe:** HTFs for swing levels, LTFs for execution.
• **Volume:** High volume at level = stronger signal.
• **Context:** Trade with broader trend or at least avoid counter-trend without confirmation.
• **Risk:** Always pre-define invalidation; structures fail in chop.

---

# 🔔 Alerts

• **New SUP Created** – When a qualifying inefficient candle prints a SUP midpoint.
• **SUP Touched/Invalidated** – When price touches within tolerance.
• **New FVG Detected** – When a valid gap forms per your rules.

> **Tip:** Set alerts *Once Per Bar Close* on HTFs; *Once* on LTFs to avoid noise.

---

# 🧑‍💻 Technical Notes

• **Percentile vs ATR:** Percentile adapts to volatility; ATR gives consistency for backtesting.
• **FVG Direction Logic:** Gap above price = bearish (expect up-fill); below = bullish (expect down-fill).
• **Performance:** Limits on lines/boxes and auto-aging keep things snappy.

---

# ⚠️ Limitations

• Imbalances are **context tools**, not signals by themselves.
• Works best with trend or clear impulses; expect noise in narrow ranges.
• Lower-timeframe gaps can be plentiful and lower quality.

---

# 📌 Version & Requirements

• **Pine Script v6**
• Heavy drawings may require **TradingView Pro** or higher (object limits).

---

*For best results, combine with your existing trading strategy and proper risk management.*

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.