OPEN-SOURCE SCRIPT
Updated Adaptive Trend Cycle Oscillator

Adaptive Trend Cycle Oscillator
A bounded cycle-timing oscillator that does two things most cycle tools don't: it tunes its own period to the market's measured rhythm, and it scores its own signals forward on your chart in plain language — so you can see at a glance whether to act or wait.
What it is. A 0-100-style cycle line (shown −100…+100) that highlights up-phases and down-phases and marks turns out of oversold/overbought. A dashboard translates the current state into a one-word verdict and an honest conviction read.
Why these parts are combined (not a mashup for show). Three classical ideas are fused because each fixes the previous one's flaw. A trend-difference line (fast average minus slow average) captures direction but is unbounded and late at turns. Running it through a double stochastic normalization bounds it and sharpens the cyclical phase, so reversals show sooner with less whipsaw. The remaining weakness is the fixed normalization length — real cycles stretch and compress — so the length is set from a measured dominant cycle (autocorrelation of a band-passed price), making the oscillator self-tuning. The three only work as one tool; separately each is incomplete.
How it works. (1) Dominant cycle: band-pass filter → autocorrelation across lags → Fourier transform → power spectrum → dominant period via its centre of gravity. (2) Oscillator: trend-difference → stochastic over the measured period → smooth → stochastic → smooth. (3) Calibration: each signal is labelled by a triple barrier — a profit target and an equal stop in ATR units, plus a time limit — so a "win" means the target was reached before the stop. Results 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 first (Long/Short signal, Watch, or Wait). Check Conviction — it only reads "High" when that signal type shows a positive edge that survives the statistical test on this symbol; otherwise treat the signal as context. Green wave above the mid line is an up-phase, red below is a down-phase; shaded bands are extremes. Best used alongside your own trend and risk plan, not alone.
What's original. The self-tuning period, the forward triple-barrier calibration with an out-of-sample split, and a conviction read that openly admits when there's no proven edge — rather than presenting every signal as equally reliable.
Inputs. Price source (change it to use any market), reading mode (Simple/Pro), cycle and self-tuning controls, signal zones, full calibration settings, and an auto-adapting dashboard that stays 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, and the cycle estimate lags at regime shifts.
Disclaimer: for research and education only. Not financial advice. Trading carries risk of loss; manage your own positions.
A bounded cycle-timing oscillator that does two things most cycle tools don't: it tunes its own period to the market's measured rhythm, and it scores its own signals forward on your chart in plain language — so you can see at a glance whether to act or wait.
What it is. A 0-100-style cycle line (shown −100…+100) that highlights up-phases and down-phases and marks turns out of oversold/overbought. A dashboard translates the current state into a one-word verdict and an honest conviction read.
Why these parts are combined (not a mashup for show). Three classical ideas are fused because each fixes the previous one's flaw. A trend-difference line (fast average minus slow average) captures direction but is unbounded and late at turns. Running it through a double stochastic normalization bounds it and sharpens the cyclical phase, so reversals show sooner with less whipsaw. The remaining weakness is the fixed normalization length — real cycles stretch and compress — so the length is set from a measured dominant cycle (autocorrelation of a band-passed price), making the oscillator self-tuning. The three only work as one tool; separately each is incomplete.
How it works. (1) Dominant cycle: band-pass filter → autocorrelation across lags → Fourier transform → power spectrum → dominant period via its centre of gravity. (2) Oscillator: trend-difference → stochastic over the measured period → smooth → stochastic → smooth. (3) Calibration: each signal is labelled by a triple barrier — a profit target and an equal stop in ATR units, plus a time limit — so a "win" means the target was reached before the stop. Results 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 first (Long/Short signal, Watch, or Wait). Check Conviction — it only reads "High" when that signal type shows a positive edge that survives the statistical test on this symbol; otherwise treat the signal as context. Green wave above the mid line is an up-phase, red below is a down-phase; shaded bands are extremes. Best used alongside your own trend and risk plan, not alone.
What's original. The self-tuning period, the forward triple-barrier calibration with an out-of-sample split, and a conviction read that openly admits when there's no proven edge — rather than presenting every signal as equally reliable.
Inputs. Price source (change it to use any market), reading mode (Simple/Pro), cycle and self-tuning controls, signal zones, full calibration settings, and an auto-adapting dashboard that stays 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, and the cycle estimate lags at regime shifts.
Disclaimer: for research and education only. Not financial advice. Trading carries risk of loss; manage your own positions.
Release Notes
Adaptive Trend Cycle Oscillator — v2Two 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, signals and stats byte-for-byte unchanged.
New (optional, off by default): cycle-strength gate. Turns fire only when a real dominant cycle is actually present (autocorrelation at the measured cycle period clears a threshold), suppressing cycle-timing signals in trends or no-cycle conditions. It reuses the engine's existing periodogram, and flows through the calibration so the Edge row tells you whether it helps. Existing behaviour is unchanged until you turn it on.
Release Notes
v1.1 — Robustness + finishing pass- Robustness (important): the self-tuning cycle engine recomputed thousands of cosine/sine values
every bar, which could trip the "calculation timed out" error on deep history or very low
timeframes. Those values are constant, so they are now built once into a lookup table — identical
output, far lighter, no timeout. The script runs smoothly on 1m and long histories.
- Added a warm-up guard: while the self-tuning cycle is on, signals are held (dashboard shows
"Warming up") until the engine has enough history to tune meaningfully. Fixed-length mode is
unaffected.
- 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
signal 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.
Descriptive research tooling, in-sample statistics, not investment advice.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.