PROTECTED SOURCE SCRIPT

Pivot Extension & FOMO Guardrail

276
# Pivot Extension & FOMO Guardrail — User & Publishing Guide

A Pine Script v6 indicator for the Qullamaggie / Minervini momentum framework. It turns *discipline at the moment of entry* into a visual guardrail on the chart, and computes your stop and position size from the same structure inputs.

---

## 1. What it is and why it exists

Most momentum traders don't lose money because they can't find breakouts — they lose because of three execution errors: **chasing extended setups (FOMO)**, **placing stops inside the swing-low cluster** (so noise shakes them out), and **inconsistent position sizing** (sizing by gut feel instead of by risk).

This indicator attacks all three by making them visible *before* you click buy:

- It auto-detects the breakout **pivot** (the ceiling you broke) and measures how far above it price currently is, in **ADR** units.
- It paints an **ideal entry band** (green), an **acceptable** band (yellow), and an **extended / FOMO zone** (red background) so chasing becomes something you have to override, not something you drift into.
- It draws a **structural stop** *below* the swing-low cluster.
- It sizes the position so a stop-out always costs the **same fixed % of NAV**, capped by a maximum exposure limit.

It is a **decision-support indicator, not a strategy and not a buy signal**. It makes no performance claims.

---

## 2. Quick start (under 5 minutes)

1. Open a **daily** chart of a stock that is in a base or breaking out.
2. Open the **Pine Editor** (bottom panel of the chart).
3. Paste the contents of `pivot_fomo_guardrail_en.pine` and click **Add to chart**.
4. Open the indicator **Settings** and set **Account NAV**, **Risk per trade %**, and **Max exposure %** to your real numbers.

The dashboard appears top-right; the pivot line, bands, and stop appear on the chart.

---

## 3. Settings reference

All inputs are grouped. Defaults are tuned for daily-timeframe US momentum names; tune to your instrument.

| Group | Input | Default | What it controls |
|---|---|---|---|
| 1) Pivot Detection | Pivot left bars | 10 | How many bars left must be lower for a swing high to count. Larger = fewer, more significant pivots. |
| | Pivot right bars | 10 | Bars right needed to *confirm* a pivot. The newest pivot is drawn this many bars late (see Caveats). |
| 2) ADR / Extension | ADR length (days) | 20 | Lookback for Average Daily Range. |
| | Ideal entry band (×ADR) | 0.5 | Green zone: pivot to pivot + 0.5 ADR. Entering here = green light. |
| | FOMO threshold (×ADR) | 1.0 | Above pivot + 1.0 ADR = extended entry, fires the FOMO warning. |
| 3) Structural Stop | Swing-low lookback | 10 | Bars used to find the recent swing low. |
| | ATR length | 14 | ATR used for the stop buffer. |
| | Stop buffer (×ATR) | 0.2 | Stop = swing low − 0.2 × ATR, placing it *below* the cluster. |
| 4) Trend Filter | Trend MA length | 50 | Moving average for the trend check. |
| | MA type | SMA | SMA or EMA. |
| 5) Position Sizing | Account NAV ($) | 100000 | Your account equity. |
| | Risk per trade (% NAV) | 0.5 | Dollar risk budget per trade. |
| | Max position exposure (% NAV) | 15 | Position-value cap (prevents over-concentration). |

---

## 4. Reading the chart

| Element | Meaning |
|---|---|
| **Blue line** | The **pivot** — the most recent confirmed swing-high (the ceiling you measure extension from). |
| **Green fill** | **Ideal entry band** (pivot → pivot + 0.5 ADR). Entering here is "right at the pivot." |
| **Yellow fill** | **Acceptable but getting extended** (0.5 → 1.0 ADR above pivot). |
| **Red background** | Price is in the **FOMO zone** (≥ 1.0 ADR above pivot). The move is extended — the time to enter has passed. |
| **Green background** | A **clean breakout** just printed (crossed pivot, not extended, above a rising MA). |
| **Red line** | The **structural stop** (swing low − 0.2 × ATR). |
| **Green ▲ "GO"** | Clean breakout marker (below the bar). |
| **Red ✕ "FOMO"** | Extended breakout marker — do not chase (above the bar). |

---

## 5. Reading the dashboard (top-right)

| Row | Shows | Color logic |
|---|---|---|
| ADR% | Average daily range as a percent | — |
| Pivot | Current pivot price | — |
| Extension | How far above pivot, in ADR | Green ≤ 0.5 · Orange 0.5–1.0 · Red ≥ 1.0 |
| FOMO | `✓ OK` or `⚠ EXT` | Matches Extension color |
| Trend ↑50MA | Above a *rising* 50MA? | Green ✓ / Red ✗ |
| Stop | Stop price and % below current | — |
| Risk/share | Dollars lost per share if stopped | — |
| Shares | **Fixed-risk position size** (with `(expo cap)` note if capped) | Teal normal · Orange if capped |
| Position $/% | Position value and % of NAV | — |

---

## 6. How the position size is computed

This is **fixed-risk sizing**: regardless of price or volatility, a stop-out always costs the same fixed % of NAV. Size is derived from the stop, not from a feeling.

1. **Risk budget** = NAV × Risk% — e.g. `$100,000 × 0.5% = $500`. The most you'll lose on this trade.
2. **Risk per share** = current price − stop price — e.g. `$50.60 − $47.20 = $3.40`.
3. **Raw shares** = ⌊Risk budget ÷ Risk per share⌋ = `⌊500 / 3.40⌋ = 147`. A stop-out now costs `147 × 3.40 ≈ $500`.
4. **Exposure cap** = ⌊NAV × MaxExpo% ÷ price⌋ = `⌊100,000 × 15% / 50.60⌋ = 296`. **Final shares = min(raw, cap) = 147.**

**Key property:** a wider stop → larger risk-per-share → *fewer* shares; a tighter stop → *more* shares — but the dollar loss on a stop-out stays constant. The exposure cap only binds when the stop is very tight (it then lowers your actual risk below budget, which is fine).

---

## 7. Worked examples

All examples assume NAV $100,000, risk 0.5% ($500 budget), max exposure 15%, ADR 4%.

### Example A — Clean breakout (GO)

| | |
|---|---|
| Pivot (broken ceiling) | $50.00 |
| ADR (4% of $50) | ≈ $2.00 |
| Ideal band top / FOMO threshold | $51.00 / $52.00 |
| Current price | $50.60 |
| **Extension** | (50.60 − 50.00) / 2.00 = **0.30× ADR → green** |
| Trend | above rising 50MA → **✓** |
| Swing low / ATR / stop | 47.50 / 1.50 → **$47.20** |
| Risk per share | 50.60 − 47.20 = **$3.40** |
| Shares | ⌊500 / 3.40⌋ = **147** (position $7,438 = 7.4% NAV, under cap) |

**Dashboard:** GO triangle, green background, Extension 0.30× (green), FOMO ✓ OK, Trend ✓, Shares 147. Stop-out cost: `147 × 3.40 ≈ $500` ✓. This is the trade you take.

### Example B — Extended entry (FOMO, do not chase)

Same stock three days later, after it ran.

| | |
|---|---|
| Pivot (unchanged) | $50.00 |
| Current price | $53.50 |
| **Extension** | (53.50 − 50.00) / 2.00 = **1.75× ADR → red** |

**Dashboard:** red background, FOMO ⚠ EXT, Extension 1.75× (red). The structural stop is still ~$47.20, so risk per share is now `53.50 − 47.20 = $6.30` — to keep $500 risk you'd size down to ⌊500/6.30⌋ = 79 shares, *and* any normal pullback shakes you out because you're 1.75 ADR extended. **The guardrail's job is to stop this entry.** The time to buy was $50.60, not here.

### Example C — Tight stop hits the exposure cap

A $20 stock with a very tight base.

| | |
|---|---|
| Pivot / current price | $20.00 / $20.15 |
| Swing low / ATR / stop | 19.60 / 0.40 → **$19.52** |
| Risk per share | 20.15 − 19.52 = **$0.63** |
| Raw shares | ⌊500 / 0.63⌋ = 793 → position $15,979 = **16% NAV (exceeds 15% cap!)** |
| Exposure cap | ⌊100,000 × 15% / 20.15⌋ = 744 |
| **Final shares** | min(793, 744) = **744 `(expo cap)`** |

**Dashboard:** Shares shows `744 (expo cap)` in orange. Actual risk drops to `744 × 0.63 ≈ $469` (under budget). When the stop is very tight, the cap protects you from over-concentration — exactly as intended.

### Example D — Same risk across very different prices

This is the whole point of fixed-risk sizing. Two trades, 20× price difference, identical dollar risk:

| Stock | Price | Stop | Risk/share | Shares | Position | Stop-out cost |
|---|---|---|---|---|---|---|
| HIGH | $300 | $288 | $12.00 | ⌊500/12⌋ = 41 | $12,300 (12.3%) | $492 |
| LOW | $15 | $14.30 | $0.70 | ⌊500/0.70⌋ = 714 | $10,710 (10.7%) | $500 |

Both risk ≈ $500 = 0.5% NAV. The size adapts to the price and stop; the risk does not move. This is what kills inconsistent sizing.

---

## 8. Setting up alerts

The script exposes three `alertcondition`s. To use them: click the **Alert** (clock) icon → **Condition** → select *Pivot Extension & FOMO Guardrail* → pick one of:

- **Clean breakout (green light)** — fires when price crosses the pivot, is not extended, and is above a rising 50MA.
- **Extended breakout (FOMO warning)** — fires when a breakout happens but price is already ≥ the FOMO threshold. Don't chase.
- **Entered FOMO zone** — fires when extension crosses above the FOMO threshold.

Set the alert to **Once Per Bar Close** to avoid intrabar repainting on the alert itself.

---

## 9. Caveats and notes

- **Real-time pivot lag.** A pivot needs `Pivot right bars` to confirm, so the *newest* swing high is drawn late. This is correct for this tool: the ceiling you break formed *before* the breakout and is already confirmed, so the blue line is always the confirmed level you're breaking. In a multi-leg run-up, the most recent leg's top isn't confirmed yet, so extension is measured from the prior confirmed pivot — which shows *more* extension, the safe direction for a FOMO guard.
- **Timeframe.** Defaults are for the daily chart. On intraday charts, retune pivot left/right, ADR length, and stop lookback.
- **Extension uses close, not high.** Intrabar spikes won't flip the state; the honest "if I enter now" measure is the close.
- **Not financial advice.** This is a decision-support tool. It does not predict price and makes no performance claims. Do your own research and manage risk.

---

## 10. Publishing to TradingView

### 10.1 Private vs Public — pick the right one

- **Private (recommended for a personal tool).** Not moderated. Only people you give the link to can see it. You can **edit and delete** private scripts. Good for personal use or sharing with a few people. Note: you cannot reference a private publication anywhere in public TradingView content.
- **Public.** Subject to moderation; must comply with the House Rules and Script Publishing Rules. You **cannot delete** a public script once published (a moderated/hidden script can't be made visible again — you'd publish a new compliant version).

### 10.2 Access types (public only)

- **Open (open-source).** Pine code visible to everyone (Mozilla license by default; you may choose another). **This is the correct choice for this indicator if you publish publicly** — it builds on built-ins, and protected/invite-only scripts that reproduce built-in behavior are not allowed.
- **Protected.** Code hidden, anyone can use. Requires Pro/Pro+/Premium. Not appropriate here.
- **Invite-only.** Code and access controlled per user. Premium only; must meet Vendor Requirements. Not appropriate here.

### 10.3 Pre-publish checklist

The publication **copies your current chart**, including any other scripts, drawings, and images. Before publishing:

- [ ] Remove every other indicator and drawing from the chart (leave only this script).
- [ ] Pick a clean, representative symbol and timeframe where the bands, stop, and a GO/FOMO marker are clearly visible.
- [ ] Make sure the symbol, timeframe, and indicator name are visible on the chart.
- [ ] Confirm the script is **active on the chart** (Add to chart) — it must be running to publish.
- [ ] Read the House Rules, Script Publishing Rules, and (if relevant) Vendor Requirements.

### 10.4 Step-by-step

1. Load the script in the **Pine Editor** and **Add to chart**.
2. Clean the chart per the checklist above.
3. In the Pine Editor, click **Publish indicator** (top-right of the editor). A reminder popup about House Rules appears for public scripts.
4. The **title** defaults to the `indicator()` title — keep it, it makes the script searchable.
5. Paste a **description** (ready-to-use text in 10.6).
6. Choose **visibility** (Private or Public). For public, choose access type **Open**.
7. Select at least one **category** (mandatory) and add optional custom **tags** (e.g. `momentum`, `risk management`, `position sizing`, `breakout`, `ADR`).
8. Click **Publish**.

### 10.5 House Rules notes specific to this script

- **Originality / no trivial mashups.** Input changes, renaming, and version conversion don't count as improvements, and pure "merge two indicators" mashups are rejected. Your description **must justify why the components belong together** — the behavioral-guardrail framing does this (extension, stop, and size are computed from one consistent structure model and answer one decision). The 10.6 description already makes this case.
- **Write for non-coders.** Most users can't read Pine; the description carries the explanation of how to use it.
- **No performance claims.** Don't claim it's profitable or advertise it as free/limited-time. State plainly that it's decision support and not a buy signal (the 10.6 text does).
- **It's an indicator, not a strategy,** so the strategy-backtesting rules (realistic commission/slippage, 100+ trades, no caution warnings) don't apply.

### 10.6 Ready-to-paste publication description

> **Pivot Extension & FOMO Guardrail**
>
> This indicator turns entry discipline into a visual guardrail. Instead of only signaling *where* to enter, it shows whether you're entering at the right *distance* from the breakout pivot — the single most common way momentum traders hurt themselves by chasing extended setups.
>
> **What it does**
> - Auto-detects the most recent confirmed swing-high pivot — the breakout ceiling you measure extension from.
> - Draws three zones in ADR (Average Daily Range) units: an ideal entry band right above the pivot (green), an acceptable-but-getting-extended band (yellow), and an extended / FOMO zone (red background) where chasing is statistically poor.
> - Marks a structural stop below the recent swing-low cluster (swing low − buffer × ATR), so the stop clears noise instead of sitting inside it.
> - Computes a fixed-risk position size: shares are sized so a stop-out always costs the same fixed % of account NAV, with a maximum-exposure cap to prevent over-concentration when the stop is very tight.
> - Filters by trend: flags whether price is above a *rising* moving average.
>
> **Why the components belong together**
> Extension, stop placement, and position size aren't independent. The stop defines risk-per-share, which defines the size; the extension tells you whether the entry is even worth taking. The indicator derives all three from one consistent set of structure inputs (pivot, ADR, ATR), so the dashboard answers "should I enter, where's my stop, and how many shares" in a single read.
>
> **How to use**
> Add it to a daily chart of a stock in a base or breaking out. Read the dashboard top-right: if Extension is inside the green band, Trend is ✓, and a GO marker prints, the entry is near the pivot. If the background turns red (FOMO), the move is extended — the time to enter has passed. Use the Shares value as a fixed-risk size, not a target to fill at any price. Inputs are grouped for pivot sensitivity, ADR/extension thresholds, stop buffer, trend MA, and account sizing — tune them to your instrument and timeframe.
>
> This is a decision-support tool, not a strategy and not a signal to buy. It makes no performance claims. Always do your own research and manage risk.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.