OPEN-SOURCE SCRIPT
Cập nhật

Multi-Period Divergence Oscillator

439
Multi-Period Divergence Oscillator

A bounded buying-pressure oscillator built to expose divergences that are corroborated across multiple measurement windows at once — and, optionally, across timeframes — then scores its own divergences forward on your chart in plain language so you can see at a glance whether to act or wait.

Why this construction (not a mashup for show). Single-window oscillators throw frequent, fragile divergences. The fix, by design, is to measure buying pressure over three windows (fast, medium, slow) and weight them into one line, so a divergence only forms when short-, medium- and long-horizon pressure agree. This tool layers two further filters that each remove a class of false signal: higher-timeframe confirmation (a divergence that also shows on a higher timeframe is far less likely to be noise), and forward calibration (instead of assuming a divergence "should" reverse price, it measures whether it actually has, on this symbol, with realistic profit/stop outcomes). The oscillator, the divergence engine, the MTF check and the calibration form one coherent tool — none alone is sufficient, which is why they're combined.

How it works. Buying pressure = close − min(low, prior close); true range = max(high, prior close) − min(low, prior close). The oscillator weights their sums over three windows (default 7/14/28). Divergence is detected from confirmed price pivots versus the oscillator (regular and optional hidden). With HTF confirmation on, a signal 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. Best used alongside structure, not alone.

What's original. Higher-timeframe divergence confirmation on a multi-window 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. High/Low/Close sources (change them for any market), reading mode (Simple/Pro), oscillator 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.
Phát hành các Ghi chú
Multi-Period 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.
Phát hành các Ghi chú
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.

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.