OPEN-SOURCE SCRIPT
Atualizado

Smoothed Momentum Divergence Oscillator

437
Smoothed Momentum Divergence Oscillator

A bounded momentum oscillator whose momentum is double-smoothed — once on the price change and once on its size — which makes its swings unusually clean and well suited to divergence. It adds higher-timeframe confirmation and a plain-language forward-calibration layer, so you can see at a glance whether a divergence is corroborated and whether it has actually paid on this symbol.

Why this construction (not a mashup for show). Each part removes a weakness of raw divergence. Raw momentum is jagged, so single-pass divergence is noisy — smoothing the price change twice (and dividing by the twice-smoothed size of the change) produces a clean bounded line whose pivots are stable, which is the core reason this construction suits divergence at all. Higher-timeframe confirmation removes single-timeframe noise: a divergence that also shows on a higher timeframe is far less likely to be a fluke. Forward calibration removes blind faith: instead of assuming a divergence "should" reverse price, it measures whether it actually has, with realistic profit/stop outcomes. The smoothed oscillator, the divergence engine, the MTF check and the calibration form one coherent tool.
How it works. Momentum = double-smoothed price change ÷ double-smoothed absolute price change, scaled to a bounded line with a signal average. Divergence is detected from confirmed price pivots versus the oscillator (regular and optional hidden). With MTF confirmation on, a divergence counts only if a same-direction divergence is also present on the chosen higher timeframe. Each signal is then labelled by a triple barrier — a profit target and equal stop in ATR units plus a time limit — split into in-sample and recent out-of-sample, with a confidence interval and a multiple-testing check.

How to use. Read the Verdict row (Bull/Bear divergence confirmed, "unconfirmed," or Wait) and the Conviction row, which reads "High" only when that divergence type shows a positive edge that survives the test on this symbol. A divergence is a reversal warning, not a trend signal — pair it with your own entry trigger and risk plan.

What's original. Higher-timeframe divergence confirmation on a double-smoothed oscillator, the forward triple-barrier calibration with an out-of-sample split, and a conviction read that openly admits when there's no proven edge.

Inputs. Price/High/Low sources (change them for any market), reading mode (Simple/Pro), momentum windows, divergence and HTF-confirm controls, full calibration settings, and an auto-adapting dashboard legible on dark or light charts. Defaults are tuned for NSE:NIFTY1! intraday.

Honesty & limitations. Edge figures are computed on this chart's own history with overlapping windows and no costs — context, not a guaranteed backtest; past behaviour doesn't predict the future. Divergence is inherently early and can persist before price turns.

Disclaimer: for research and education only. Not financial advice. Trading carries risk of loss; manage your own positions.
Notas de Lançamento
Minor Visual update
Notas de Lançamento
Smoothed Momentum Divergence — v2
Two changes in this update:

Performance: the forward-calibration engine now computes its triple-barrier outcome once per bar and reuses it, instead of recomputing the identical result three times — faster loading and lower runtime, with signals, stats and visuals byte-for-byte unchanged.

New (optional, off by default): regime gate. Fires each divergence only where its type has an edge — reversal (regular) divergences in ranges, continuation (hidden) divergences in trends — via an efficiency-ratio regime read. Modes: Match-type-to-regime (default), Trending-only, Ranging-only. It flows through the built-in calibration, so the Edge row tells you whether it helps on your instrument. Existing behaviour is unchanged until you turn it on.
Notas de Lançamento
v1.1 — Correctness + finishing pass

- Correctness (important): the higher-timeframe divergence check called ta.valuewhen from behind a
short-circuiting AND, so it was skipped on non-pivot bars and could report wrong HTF confirmations.
Those calls now run on every bar as Pine requires. With "Require HTF agreement" on, confirmed
divergences will be more accurate than before.
- All-timeframe: the auto higher-timeframe map now clamps sensibly on Daily/Weekly charts (→ W / M),
so it always requests a genuinely higher frame.
- Added a Data Window (EXP_) export bus so the oscillator can feed other scripts via input.source().
- Added a cost model: a new "Round-trip cost (R)" input and a Net R row. Conviction now requires a
divergence to BOTH beat its base rate (Wilson) AND survive costs — a gross edge that costs eat
through is not tradeable, and the panel now says so.

Descriptive research tooling, in-sample statistics, not investment advice.
Notas de Lançamento
R1 honest-stats standardization. The Wilson lower-bound (star rating + survivorship gate) now comes from the published ml_calib/2 library, byte-identical to the prior local helper — oscillator, marks and calibration numbers unchanged. Shared calibration engine across the divergence family.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.