OPEN-SOURCE SCRIPT
Обновлено

Potential Well Map

228
Overview

A volume or time profile tells you where price spent time. Potential Well Map tells you the forces acting at each level. It models the market as a particle drifting in a one-dimensional energy landscape and estimates that landscape directly from recent price action — the local drift (average next move) and diffusion (variance of the next move) at each price level — then integrates them into a potential curve. Its valleys are attractors (dynamical support/resistance that pulls price in); its peaks are barriers (levels price is repelled from). Two levels with identical occupancy can be opposite in dynamics — one an attractor, one a barrier — and this map tells them apart. It is a descriptive structure-and-risk map, not a predictive signal.

Why these components are ONE tool (mashup justification)

This is a four-stage chain where each stage produces something the previous one can't, and the honesty layer keeps the whole thing accountable:


Drift + diffusion per level — the raw forces. For every price bin, exponentially-decayed accumulators track the count, sum, and sum-of-squares of the next one-bar move that started there, giving the conditional first two moments (drift and diffusion) with recent regime weighted most. This is O(N) per bar — no window rebuild, no timeout.
The potential curve — the integral of drift ÷ diffusion. This turns the raw forces into a landscape whose valleys and peaks are attractors and barriers. It is the object an occupancy profile fundamentally cannot produce, because occupancy measures time spent, not the pull at a level.
Escape pressure — a bounded 0–100 breakout gauge derived from the remaining wall height between price and the nearest barrier. Because the potential is already diffusion-normalized, the escape factor is a clean exponential of the wall height, and it concentrates toward 100 as price approaches a wall.
The calibration harness — the honesty layer. When a barrier escape is flagged, did price actually travel that way more often than the unconditional base rate? It reports Hit / Base / Edge, resolved forward on confirmed bars only. The forces are a picture; the harness is the proof. Remove any one stage and the map either asserts structure it never tested, or shows a level with no dynamics behind it.


How it works

Price is detrended into a coordinate x = ln(price) − ln(slow anchor) so the distribution stays roughly centred as price trends. A grid of x-bins spans a few volatility units either side of zero. For each bin, the decayed accumulators build drift and diffusion; neighbour bins are sample-weighted-smoothed; the force (drift ÷ diffusion) is integrated into the potential; valleys and peaks that clear a prominence margin are marked as wells and barriers; and the escape pressure to each adjacent barrier is computed. Bins with too few effective samples are greyed out rather than trusted.

How to use it

Read the landscape as context. The green valley line is the active attractor — a mean-revert target. The dashed red lines are the barriers above and below. The shaded box is the expected range of a stiff well. In the dashboard, the escape pressures rise toward 100 as price nears a wall; a pin (fade-to-mean) is flagged only when price sits mid-well in a stiff, bounded valley, and an escape is flagged when price crosses a barrier after that side's pressure was already elevated. Watch the Edge row: a positive, matured Edge means escapes have led price on this instrument; near-zero means treat the map as structure only, not a trigger. It is never a standalone signal.

Universal & non-repainting

The source is an input and everything is self-scaling (vol-scaled grid, detrended coordinate), so it runs on any symbol and timeframe; defaults suit a liquid index/futures intraday chart. All statistics use closed past bars only — both the drift/diffusion accumulators and the calibration harness update solely on confirmed bars, so their numbers never inflate intrabar. The displayed landscape naturally evolves bar to bar because it is a live estimate, not a fixed level; confirmed escape and pin marks settle on the close of their bar. Edge figures are in-sample, close-to-close, with no costs — a study aid, not a backtest.

Originality

The building blocks are public physics and statistics: stochastic drift-diffusion dynamics, conditional-moment estimation of the drift and diffusion coefficients, and escape-rate theory. What's original is the application to a price series as a live, decayed, per-level energy landscape — the detrended coordinate, the exponential-memory conditional-moment accumulators, the diffusion-normalized potential integral, the prominence-gated well/barrier detection, the escape-pressure gauge, and the forward-calibration harness that scores escapes against their base rate. This is a clean-room implementation; no third-party Pine code is reused.

Concept credits


Stochastic drift-diffusion (Langevin) dynamics and the Fokker–Planck description of a probability landscape — Paul Langevin, Adriaan Fokker, Max Planck
Estimating drift and diffusion from the conditional moments of increments (Kramers–Moyal expansion) — Hendrik Kramers, José Enrique Moyal; exposition after Hannes Risken
Barrier escape / escape-rate theory — Kramers' escape-rate framework
Forward base-rate calibration discipline — standard out-of-sample evaluation practice


Disclaimer

Research and educational tool only. Not financial advice, no recommendation, no guarantee of results. It is an effective, empirical 1-D approximation of a memoryful, multi-factor market — treat "escape pressure" as a relative, normalized gauge, not a literal probability. Estimates are noisy where samples are sparse (the greyed bins). Indicators describe past behaviour; they do not predict the future. Trading carries risk of loss. Test out-of-sample and make your own decisions. The author accepts no liability.
Информация о релизе
Potential Well Map v1.1

Two changes, one statistical and one a genuine fix.

The Escape Edge now carries a Wilson 95% lower bound. The panel turns green only when that lower bound clears zero with an adequate sample, so a positive point estimate on a small sample is no longer coloured as though it were proven.

More importantly: the escape detection contained a bug. The crossover and crossunder tests were guarded by conditions that change from bar to bar — whether the barrier was armed, and whether a barrier price existed. Because Pine's and short-circuits, those stateful functions were skipped on any bar where the guard was false, corrupting the previous-value comparison they depend on. Escapes could be missed or misfired. They are now evaluated on every bar and masked afterwards.

The potential-well construction, barrier detection and regime classification are otherwise unchanged.

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.