OPEN-SOURCE SCRIPT
Cập nhật

Gamma Exposure Profile - Manual Chain Input

387
A self-contained dealer-gamma calculator. Pine cannot fetch external data, so
instead of shipping stale hardcoded levels, this script takes the option
chain as USER INPUT: paste strike rows into the settings and it computes the
full gamma exposure profile on your chart — no republishing, never stale.

What makes it original: most "GEX" scripts on TradingView approximate gamma
from price or volume. This one implements the actual model — Black-Scholes
gamma per strike from open interest and implied volatility, aggregated with
the standard dealer sign convention (long call gamma, short put gamma) — and
derives the flip point by scanning where total exposure changes sign, the
same way institutional GEX tools do.

How it works:
- Input format (one paste): a header line
`#spot=24900;dte=21;mult=5;iv=0.18;date=2026-07-17`
followed by one line per strike: `strike;callOI;putOI[;iv]`.
- Per strike, the script computes Black-Scholes gamma (r = 0) and the signed
dealer exposure `gamma x (callOI - putOI) x multiplier x spot² x 1%`.
- Gamma flip = the zero crossing of total exposure over a spot grid (closest
to spot); call/put walls = strikes with the largest positive / most
negative exposure; second walls dashed; expected move from ATM IV.
- A second optional text area takes a near-dated chain (e.g. 0-5 DTE) for
the short-term walls, drawn dotted — structure vs day-weather separation.
- The histogram next to price shows the signed per-strike profile; the
background colors the regime (above flip = long gamma, below = short
gamma); a date in the header enables a staleness warning after 36h.
- Alerts: flip cross up/down, put-wall break/reclaim, call-wall break.

How to use it: pull the option chain of the underlying index (your broker
platform or the exchange's public chain), paste the strike rows once per day,
and read the chart: above the flip, dealer hedging dampens moves (mean
reversion toward walls, pinning); below the flip it amplifies them (trend
days, trapdoor under the put wall). The levels are model estimates from your
own snapshot — context, not trade signals.

*This script is part of a consistent set of open-source session, range and
volume tools — the companions are on my profile.*
Phát hành các Ghi chú
Added the two second-order flows, computed from the same chain input.

Vanna — how dealer delta reacts to a change in implied volatility, reported per one volatility point. Positive vanna means falling vol forces dealers to buy just to stay neutral.

Charm — how dealer delta decays as time passes, per trading day. This is the mechanical flow that accumulates into expiry weeks regardless of what price does.

Both use the same dealer sign convention as the gamma exposure above (long calls, short puts) and assume r = 0. Together they describe hedging pressure that builds without price moving at all. The label shows the net of each with its dominant strike; two optional dotted lines mark those strikes.

One caveat, stated in the settings as well: unlike the gamma regime, these two are not backtested here. Read them as context, not as signals.
Phát hành các Ghi chú
Accuracy update — the pasted chain is now reproduced exactly.

- Walls, histogram and flow strikes aggregate per strike again (since v1.2
a pasted row can be a single option; the walls picked the biggest row
instead of the biggest strike).
- Flip search refines around the found crossing instead of stopping at the
coarse grid.
- Expected move: ATM IV from the optional header key aiv=, or the median of
the six rows closest to spot; sqrt(252) trading days.

Verified against our reference computation: every level within one point.
Phát hành các Ghi chú
One paste now serves every chart.

The script reads six input fields as a single paste. A block header may name
its market — #market=DAX;spot=... — and the script automatically picks the
block matching the chart symbol (DAX, NQ, DOW, GOLD, FTSE, SPX; a manual
override covers anything else). map=near in the header marks a near-dated
card, so structure and near chains can live in the same field.

Why six fields: TradingView silently truncates every text input at roughly
10,900 characters - measured, not documented anywhere. A full chain no longer
fits into one field, so large pastes are split across fields and reassembled
by the script. If your levels ever look odd, check that the last line of each
field arrived complete.

Blocks without a market= key keep the old behaviour exactly: field 1 is the
structure chain, field 2 the near chain. Existing pastes work unchanged.
Phát hành các Ghi chú
Minor: the label now shows which market block is active (useful with
multi-market pastes). Also refreshes the publication chart image.
Phát hành các Ghi chú
One input field pair per market, and each card can span two fields.

Until now all markets shared generic paste fields and a market= key in the
header decided which rows belonged to your chart. That filter proved
unreliable — a Dow chart could end up computing the DAX chain. It is gone.

Each market now has its own fields: DAX, NQ, DOW, GOLD, FTSE, SPX, each with
a structure and a near card, and a second field per card for chains that do
not fit in one (TradingView truncates a text field at about 10,900
characters without saying so). A generic pair still covers single-market use
and symbols the auto-detection does not know.

The wider budget matters: on a large chain the trimmed rows used to shift
the gamma flip by hundreds of points while the walls stayed correct — walls
are single strikes, the flip is a sum over the whole chain. Checked against
the reference computation: DAX -0.6, Dow -0.3, Gold +0.1, Nasdaq +14 points.

Also in this release: per-strike expiry in the chain format, vanna and charm
from the same chain, expected move on trading days, and walls aggregated per
strike rather than per row.

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.