OPEN-SOURCE SCRIPT
Cập nhật

Composite Reversion Oscillator

379
Composite Reversion Oscillator

A short-term mean-reversion oscillator that blends three different "how stretched is this?" reads into one 0–100 line: how overbought/oversold momentum is, how long the current up/down streak has run, and where the latest return ranks against its own recent history. Each measures a different face of over-extension; together they flag exhaustion more reliably than any one alone.

Why these parts are combined (not a mashup for show). A short momentum oscillator flags overbought/oversold but ignores persistence. A streak read (an oscillator of the consecutive up/down-close count) captures persistence it misses — three green closes isn't one. A return-rank read captures the size of the latest move relative to its own norm, which neither of the others sees. Averaging the three yields a composite that only reaches an extreme when momentum, streak and move-size all agree — far fewer false "oversold" prints.

What's different here. Rather than presenting the composite as a fixed rule, it forward-calibrates whether those agreed extremes actually revert on this symbol, with an out-of-sample split and a multiple-testing check — because mean-reversion edges are regime-dependent and decay, which is exactly where symbol-specific honesty matters most. Signals fire once per excursion (no zone-edge whipsaw).

How it works. Component 1: a short-period momentum oscillator of price. Component 2: the same oscillator applied to the signed consecutive-close streak. Component 3: the percentile rank of the latest return within a recent window. The composite is their average, mapped to a ±100 pane. A long fires on the cross up out of oversold (and locks out until the line recovers to mid); a short mirrors it. Each 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.

How to use. Read the Verdict (Long/Short/Watch/Wait) and the Conviction, which reads "High" only when that turn type shows a positive edge that survives the test here — otherwise it openly says so. Best used with your own trend and risk plan, not alone. Non-repainting.

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ú
Minor update
Phát hành các Ghi chú
What changed

Correctness fix (measured down-base rate). The down-side base rate was approximated as 100 − up%. Because an ATR target and stop can both be hit on the same bar (a tie), that complement counted ties as "down," understating the short-side edge and making short conviction pessimistic. Down-outcomes are now counted independently (baseWdn), so long-edge and short-edge are measured apples-to-apples. Up% + Dn% may now sum to slightly under 100 — the small gap is the honest tie fraction.

Optimization (no duplicate barrier). The long and short branches recomputed the exact triple barrier the base rate had already computed (identical entry and ATR at close[calHor]). They now reuse that single result, removing up to two redundant f_firstHit loops per signal bar and four dead locals. Also dropped the redundant cnt counter in the return-rank loop (it always equalled rankLen).

Value-add (component agreement). The Composite row now shows how many of the three reads (momentum / streak / return-rank) agree on the current extreme — e.g. 18/100 · 3/3 agree — making the script's whole premise visible: a unanimous extreme is stronger than a single-factor one. Exported as ComponentAgree.

Confirmed already-present. Vendor-neutral naming (no "Connors"), plain-language Verdict/Conviction, adaptive light/dark theme, NIFTY defaults, Price-source input, generic Data-Window exports, once-per-excursion signal arming, and full concept credits — all in place, left intact.

Note on the core math

The three-component composite (momentum + streak-RSI + return percentrank), the once-per-excursion arming, and the Wilson/Bonferroni calibration are correctly implemented. No other bugs; no dead variables remain.
Phát hành các Ghi chú
v1.1 — Finishing pass (no engine change)

- Added a Data Window (EXP_) export bus so the composite, its three components and the signal edge
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
reversion 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.
- Added the MPL-2.0 licence header.
- No change to the three-factor composite, the signal logic or the forward calibration — everyday
behaviour is identical.

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.