OPEN-SOURCE SCRIPT
已更新

Skew Divergence Oscillator

445
Skew Divergence Oscillator

A bounded oscillator built from the rolling skewness (asymmetry) of returns — whether recent moves lean toward big up-days or big down-days — with a divergence engine that compares that asymmetry against price. The read most tools miss: when price makes a new high but return skew is turning down (large down-moves creeping in), the advance is quietly losing its character before price confirms it. It estimates skew from higher-resolution realized data, confirms divergences on a higher timeframe, and forward-calibrates whether they pay on the chart you're viewing — in plain language.

Why these parts are combined (not a mashup for show). Each fixes a flaw in the previous one. Skewness is a distributional read price action alone doesn't show — it captures which tail is getting heavier, a leading change in market character. Realized estimation measures skew from intrabar returns instead of one value per bar, so short-window skew isn't jumpy — the standard approach in modern risk research. Divergence relates that asymmetry back to price, turning a statistic into a timing read. Higher-timeframe confirmation and forward calibration remove single-timeframe noise and blind faith respectively. Together they form one coherent tool.

How it works. Returns feed a rolling third standardized moment (skew = m3/sd³). With realized estimation on, skew is computed from a lower-timeframe return stream (confirmed only). It's standardized and soft-bounded to ±100. Divergence is detected from confirmed price pivots versus the skew line (regular and optional hidden); with MTF on, it counts only if the higher timeframe agrees. Each signal is 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 (Bull/Bear skew divergence confirmed, unconfirmed, or Wait) and the Conviction, which reads "High" only when that divergence type shows a positive edge that survives the test on this symbol — otherwise it openly says "context only" or "no proven edge here." A skew divergence is an early character warning, not a trend signal — pair it with your own entry trigger and risk plan.

What's original. The realized-skew engine as a divergence source, the higher-timeframe confirmation layer, the triple-barrier forward calibration with an out-of-sample split, and a conviction read that admits when an apparent edge isn't statistically real.

Honesty & limitations. Skew from short windows is noisy. 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. Non-repainting: pivots confirm late and never move; realized and HTF reads use confirmed data only.

Disclaimer: for research and education only. Not financial advice. Trading carries risk of loss; manage your own positions.
版本注释
Performance upgrade: the forward-calibration engine now computes its triple-barrier outcome once per bar and reuses it, instead of recomputing the identical result three times — noticeably faster loading and lower runtime with byte-for-byte identical signals, stats, and visuals. No behaviour, inputs, or outputs changed. Same tool, leaner engine.
版本注释
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.
版本注释
v1.4 — Three additive layers over v1.1: robust normalization, an optional regime gate, and a 3-window extreme consensus. The realized-skew engine, the divergence detection, the higher-timeframe confirmation and the triple-barrier / Net-R calibration are all unchanged — set Normalization = "Classic (mean/stdev)" to reproduce the exact v1.1 read.

1. Robust MAD normalization (v1.2 · default on). Skewness is itself an outlier-driven statistic — one fat-tailed bar can dominate it — so a mean/stdev z on top double-counts those extremes. The skew series can now be standardized with a median/MAD z-score (median absolute deviation ×1.4826), which keeps the σ scale stable and the divergences comparable across regimes. Selectable via "Normalization"; set "Classic (mean/stdev)" for the original.

2. Regime gate (v1.3, opt-in, default Off). An optional Kaufman efficiency-ratio filter that can restrict actionable Buy/Sell marks (and their forward-test scoring) to a chosen regime — "Favor reverting" fires only in ranges (the natural home for reversal divergences), "Favor trending" the opposite. Default Off leaves v1.2 behaviour exactly. (This consumes only the script's own internal regime read; it is not tied to any external indicator.)

3. 3-window extreme consensus (v1.4 · opt-in, default off). The skew z can be taken as the MEDIAN of the z at half, one and double the normalization window — extreme only when short, medium and long agree, removing the arbitrariness of a single lookback.

What is unchanged. The rolling third-standardized-moment skew, the optional realized (lower-timeframe) estimation, the confirmed-pivot regular + hidden divergence, the higher-timeframe confirmation gate, and the full forward-calibration harness (triple-barrier, in/out-of-sample split, Wilson stars, Bonferroni multi-test, cost-aware Net R) are byte-for-byte v1.1. The new layers only read existing series; no new plot or export was added.

Still an early WARNING about changing character, not a trend signal — skew from short windows is noisy. Non-repaint: late-confirming pivots; realized and HTF reads use confirmed values only; calibration resolves on confirmed bars. Concept credits unchanged (standardized third moment; realized higher-moment estimation; López de Prado triple-barrier; Wilson; Bonferroni; Kaufman efficiency ratio).
版本注释
v1.5 — R1 honest-stats standardization. The reliability scoring is now backed by the published calibration libraries instead of local copies: robust-z via ml_robuststats/2 (byte-identical formula, so the oscillator and signals are unchanged), and the Wilson-floored star rating + deflated "survives" edge gate via ml_calib/2. A new optional time-of-day significance gate (group 7, default OFF) can restrict divergences to statistically live intraday slots via ml_session/2. Imports are pinned to the exact published v2 versions. Same calibration engine now shared across the whole divergence family — numbers are directly comparable script to script.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。