OPEN-SOURCE SCRIPT

GBM Projection Cone (Ito)

360
GBM Projection Cone (Itō)

A geometric Brownian motion probability cone derived analytically from Itō's lemma — no random simulation required, no path-to-path variance, identical output on every reload. The cone shows where price should be in the future under a GBM model fitted to the recent log-return distribution.
The output is three concentric ±σ bands (68%, 95%, 99.7%), the arithmetic-mean path, and the Itō-corrected median path. The visible gap between mean and median is the Jensen gap — the systematic divergence that pure-arithmetic forecasting hides and lognormal compounding requires you to acknowledge.

How it works

Applying Itō's lemma to f(S, t) = ln(S):
Pine Script®

so under GBM the log-price is normally distributed:
Pine Script®


Drift μ and volatility σ are estimated from the most recent N bars of log-returns (sample mean and sample standard deviation). Percentile bands at ±kσ come straight out of the normal CDF in log-space and exponentiate back to price-space, giving the asymmetric cone characteristic of GBM.
Two center lines are computed because they answer different questions:
  • Arithmetic mean path — E[S_t] = S₀·exp(μ·t). The ensemble average across all GBM paths.
  • Itō-corrected median path — S₀·exp((μ − σ²/2)·t). The most probable single trajectory.


The mean is always above the median by Jensen's inequality, with the gap widening as volatility rises. Both are plotted so the gap is always visible.
An optional Monte Carlo overlay simulates independent GBM paths via Box-Muller normal sampling. It's there for pedagogical comparison against the closed form, not for production analysis — Monte Carlo paths re-roll on every reload. Off by default.

How to read it

The cone shows the analytical confidence regions of the projected price distribution:
  • ±1σ (68.3%) — the central body of likely outcomes
  • ±2σ (95.4%) — out to the edge of normal-regime expectations
  • ±3σ (99.7%) — beyond which an excursion would be unusually extreme under the assumed GBM dynamics


Inner bands are drawn thicker and more saturated; outer bands are thin and translucent. Endpoint labels at the right edge mark the projected price at each ±σ level at the cone's terminal bar.
The two center paths — mean (default amber) and median (default off-white) — diverge as time and volatility accumulate. Reading the divergence: a wide Jensen gap means the asset is in a high-volatility regime where ensemble-average forecasts overstate where any individual trajectory is likely to land. The median is the more honest answer for a single realised path.
The bottom-right parameter table reports estimated μ, σ, the Itō correction (−σ²/2), and the resulting Itō drift (μ − σ²/2). When the Itō drift turns negative while μ is still positive, volatility drag is overwhelming directional drift — the asset is positive-EV in expectation but negative-EV in the most-probable case.

Inputs
  • Estimation window — bars used to estimate μ and σ from observed log-returns. Default 20. Smaller windows track the recent regime; larger smooth out noise.
  • Projection bars — how many bars ahead to project. Default 20. Cone width grows with σ√t — longer horizons fan out faster under high volatility.
  • Bands — toggle ±1σ, ±2σ, ±3σ independently. Defaults: 1σ and 2σ on, 3σ off.
  • Mean path — show the arithmetic expected-value path. Default on.
  • Median path — show the Itō-corrected median path. Default on.
  • Endpoint labels — price labels at the right edge of each band. Default on.
  • Parameter table — bottom-right μ/σ/Itō readout. Default on.
  • Monte Carlo overlay — draw N random GBM realisations for comparison. Default off, non-deterministic.
  • Path count — number of MC paths when overlay is on. Default 20.
  • Colors — cone, mean path, median path.


Built-in alerts
  • Volatility spike — σ rises above 1.5× its rolling average
  • Drift turned negative — μ crosses below zero
  • Drift turned positive — μ crosses above zero
  • Itō drift crossed below zero — μ − σ²/2 turns negative (volatility drag now outpaces drift)
  • Itō drift crossed above zero — μ − σ²/2 recovers above zero

The Itō-drift alerts are the more practically useful pair. A positive arithmetic μ with negative Itō drift describes the textbook scenario where a volatile asset has positive expected return but a negative typical return — the regime where naïve EV calculations mislead position sizing.

Notes

GBM is a model. Real returns aren't truly lognormal — they exhibit fat tails, autocorrelation, and volatility clustering that GBM's i.i.d. assumption can't capture. The cone is calibrated to what the recent N bars would project forward if returns continued behaving as estimated; the more the underlying violates the model's assumptions, the less the cone reflects realised probabilities.
That said, GBM remains useful as a baseline. Most options-pricing intuition, microstructure tooling, and risk-management frameworks assume GBM-like dynamics. The cone gives you the model's own opinion about where price is likely to go — informative even when the model is wrong, because the direction and magnitude of disagreement between cone and realised price is itself signal.
The closed-form derivation is deterministic on purpose. Two reloads of the same chart produce identical cones; two reloads with the Monte Carlo overlay produce visibly different paths. For production analysis, leave Monte Carlo off. To teach yourself how MC converges to the closed form, turn it on and watch the random paths fill the bands as you increase path count.
The Itō correction (−σ²/2) is small for low-volatility assets and dominant for high-volatility ones. On a daily chart of a major equity index it's a fraction of a basis point per day; on a high-frequency crypto chart it can outweigh the directional drift entirely. The parameter table makes this visible.
This is a diagnostic tool, not a signal generator. It tells you what GBM thinks the next N bars look like.

Five years of work on a trading system left me with dozens of indicators that ultimately didn't earn a place in the final build. They're not failures — they're tools that solved problems I no longer needed solved. So instead of shelving them, I'm publishing the majority of them open-source.
If you're a discretionary trader, take what's useful. If you're a systems builder, the source is yours to dissect, modify, and improve. The best return on five years of work is for it to keep working — for someone.
If you use this script — or part of it — in your own work, please credit the original with a link back to my profile.
Note: these indicators have been updated to Pine Script v6 — some manually, some with AI assistance.

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。