INVITE-ONLY SCRIPT

TTM Squeeze Candles (Trade The Matrix) with Dynamic Strength Bar

1 520
Here is my tribute, tip of the cap to one of the greatest traders of our generation John F. Carter

It was my goal to try and simply visualize the squeeze with candle sticks, dynamic momentum, and signals all on one chart in one indicator. Please study and master the squeeze setup before trying to apply this indicator . You must have a deep understanding of how to trade the squeeze. Read "Mastering The Trade " watch JC's videos etc, and practice with a simulated or paper account before ever trying out new strategies with real money. Not financial advice, I am not a financial advisor! DYOR- with that said - I hope you like it :)

สแนปชอตhttps://www.tradingview.com/x/ukfc9xnx/The **"TTM Squeeze Candles (Custom Colors) with Dynamic Strength Bar"** is a **custom TradingView Pine Script (v6)** indicator that visualizes the **TTM Squeeze** strategy — a popular volatility-based momentum system originally developed by John Carter of TradeTheMarkets (TTM). This version enhances the classic TTM Squeeze with **custom candle coloring**, **dynamic momentum strength**, **visual alerts**, and a **real-time strength meter**.

---

## OVERVIEW: What is the TTM Squeeze?

The **TTM Squeeze** identifies periods when **volatility is contracting** (price is consolidating), followed by a **potential explosive breakout** when volatility expands.

It combines:
1. **Bollinger Bands (BB)** – measure statistical volatility
2. **Keltner Channels (KC)** – measure average true range (ATR) volatility
3. **Momentum Oscillator** – determines direction and strength of potential breakout

> **Squeeze ON** = BB inside KC → Low volatility (consolidation)
> **Squeeze OFF** = BB outside KC → Volatility expanding (breakout possible)

---

## DETAILED BREAKDOWN OF THIS INDICATOR

---

### 1. **User Inputs (Customizable Settings)**

| Input | Default | Purpose |
|------|--------|--------|
| `length` | 20 | Period for SMA, BB, KC |
| `bbMult` | 2.0 | Bollinger Band multiplier |
| `kcMult` | 1.5 | Keltner Channel ATR multiplier |
| `momentumLen` | 12 | Length for momentum regression |
| `showHistogram` | true | Show momentum histogram |
| `showStrengthMeter` | true | Show dynamic strength bar |
| `useSqueezeCandle` | true | Replace chart candles with colored squeeze candles |

---

### 2. **Core Calculations**

#### A. **Bollinger Bands**
```pinescript
basis = ta.sma(close, length)
dev = ta.stdev(close, length)
bbUpper = basis + bbMult * dev
bbLower = basis - bbMult * dev
```
- Standard BB using SMA and standard deviation.

#### B. **Keltner Channels (ATR-based)**
```pinescript
kcBasis = ta.sma(close, length)
atrv = ta.atr(length)
kcUpper = kcBasis + kcMult * atrv
kcLower = kcBasis - kcMult * atrv
```
- Uses ATR instead of stdev → more adaptive to recent volatility.

#### C. **Squeeze Condition**
```pinescript
squeezeOn = (bbUpper < kcUpper) and (bbLower > kcLower)
```
- **Squeeze ON**: BB completely inside KC → **low volatility**
- **Squeeze OFF**: BB breaks outside KC → **volatility expansion**

---

### 3. **Momentum Calculation (TTM Style)**

```pinescript
momRaw = close - basis
mom = ta.linreg(momRaw, momentumLen, 0)
```
- Measures **price deviation from the basis (SMA)** via **linear regression**
- Positive = bullish momentum, Negative = bearish

```pinescript
momRising = ta.change(mom) > 0
```
- Tracks whether momentum is increasing.

---

### 4. **Dynamic Momentum Strength (Key Feature)**

```pinescript
absMom = math.abs(mom)
strength = absMom / ta.highest(absMom, 50)
strengthSmooth = ta.sma(strength, 5)
```
- **Normalizes momentum** over last 50 bars
- **Smooths** with 5-period SMA → avoids jitter
- Result: `strengthSmooth` = **0 to 1** (0% to 100% of recent peak)

> **Strong Momentum** = `>= 50%` of recent peak
> **Weak Momentum** = `< 50%`

---

### 5. **Custom Candle Coloring Logic**

| Condition | Candle Color |
|--------|-------------|
| **Squeeze ON** | Semi-transparent **Gray** (`colSqueeze`) |
| **Squeeze OFF + Bullish + Strong** | **Cyan** (`#00FFFF`) |
| **Squeeze OFF + Bullish + Weak** | **Dark Blue** (`#00008B`) |
| **Squeeze OFF + Bearish + Strong** | **Red** (`#FF0000`) |
| **Squeeze OFF + Bearish + Weak** | **Yellow** (`#FFFF00`) |

> Wicks use same color as body
> Optional: Overrides chart candles (`useSqueezeCandle = true`)

---

### 6. **Visual Plot Elements**

| Element | Description |
|-------|-----------|
| `plotcandle()` | Draws **custom colored candles** (if enabled) |
| **Red Dots (below bar)** | Squeeze **ON** |
| **Green Triangle Up (above bar)** | Squeeze **OFF + Bullish** |
| **Red Triangle Down (above bar)** | Squeeze **OFF + Bearish** |
| **Histogram** | Momentum value, colored by direction & strength |
| **BB Lines** | Faint blue |
| **KC Lines** | Faint orange |

---

### 7. **Dynamic Squeeze Strength Bar (Bottom Center)**

```pinescript
table.new(position.bottom_center, 101, 1)
```
- A **101-cell horizontal bar** (0–100%)
- **Filled up to current `strengthSmooth * 100`**
- **Color-coded** by momentum direction & strength
- **Fades out** from filled → empty for smooth gradient
- Updates **only on last bar**

> Example:
> - 78% strength, bullish, strong → **Cyan bar filled to 78%**, fading to gray

---

### 8. **Info Label (Top-Right of Last Bar)**

```pinescript
Squeeze: ON/OFF
Momentum: +0.45
Strength: 72%
```
- Real-time status box
- Auto-updates on new bars

---

### 9. **Alert Conditions**

| Alert | Trigger |
|------|--------|
| `"Squeeze Started"` | `squeezeOn` becomes true |
| `"Squeeze Released"` | `squeezeOff AND bbUpper crosses above kcUpper` |

> Note: Only triggers on **bullish release** via `crossUp`.
> You can modify to add bearish release.

---

## HOW TO INTERPRET THE INDICATOR

| Signal | Meaning | Action |
|-------|--------|-------|
| **Gray Candles + Red Dots** | Squeeze ON → Consolidation | **Prepare** |
| **Cyan/Blue Candle + Green ▲** | Squeeze OFF → **Bullish Breakout** | **Go Long** |
| **Red/Yellow Candle + Red ▼** | Squeeze OFF → **Bearish Breakout** | **Go Short** |
| **Bright Color (Cyan/Red)** | **Strong Momentum** | Higher conviction |
| **Dim Color (Dark Blue/Yellow)** | **Weak Momentum** | Caution / possible fakeout |
| **Strength Bar >70%** | High momentum relative to recent history | Strong trend likely |

---

## TRADING STRATEGY EXAMPLE

1. **Wait for Squeeze ON** (gray candles, red dots)
2. **Watch momentum histogram** turning positive/negative
3. **Enter on Squeeze OFF** with:
- **Green triangle + cyan/dark blue candle**
- **Strength > 50%**
4. **Exit** on momentum fade or opposite signal

---

## UNIQUE FEATURES OF THIS VERSION

| Feature | Benefit |
|-------|--------|
| **Custom candle override** | Replaces default chart for clarity |
| **Dynamic strength normalization** | Compares current momentum to recent peaks |
| **Smooth strength bar** | Visual momentum intensity meter |
| **Color-coded strength levels** | Instantly see weak vs strong moves |
| **Info label** | At-a-glance stats |
| **Clean visuals** | No clutter, intuitive |

---

## LIMITATIONS & NOTES

- **Lagging by design** (uses SMAs, regression)
- **Repaints slightly** due to `ta.linreg(..., 0)` on current bar
- **Strength bar uses last 50 bars** — may vary by timeframe
- **No built-in stop-loss or TP** — use with price action or other tools

---

## BEST USED ON

- **Timeframes**: 15m, 1H, 4H, Daily
- **Markets**: Stocks, Forex, Crypto, Futures
- **Pairs well with**: Volume, VWAP, Support/Resistance

---

## SUMMARY

> **This is a highly visual, trader-friendly version of the TTM Squeeze** that:
> - **Colors candles** based on squeeze state and momentum strength
> - **Shows real-time momentum intensity** via histogram + strength bar
> - **Alerts on squeeze start/release**
> - **Normalizes momentum** for fair strength comparison
> - **Provides clean, actionable signals** for breakout trading

---

**Ideal for swing traders and day traders** looking to catch **high-momentum breakouts from low-volatility consolidations** with **clear entry signals and conviction levels**.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน