OPEN-SOURCE SCRIPT
Telah dikemas kini

Stoch

2 985
Stoch — A Refined Stochastic Oscillator with Structural Divergence Detection

This is a ground-up rebuild of the classic Stochastic oscillator, designed around one core idea: divergence lines should only ever connect real structural turning points — never cut through a pivot that should have invalidated them.

Two Divergence Detection Modes

Live — flags divergences almost immediately as price and the oscillator turn, ideal for fast-moving markets.
Confirmed — waits for a fully validated pivot before drawing anything, trading speed for certainty.

Switch between them any time; every other setting works identically in both modes.

Structurally Validated Lines
Rather than connecting to the nearest matching pivot (a common source of messy, overlapping divergence lines), this script searches back through multiple prior pivots and only accepts a connection where every pivot in between is properly ordered — guaranteeing the line always sits on the true outer envelope of the pattern. On top of that, every candidate line is checked against actual price action: a candle wick is allowed to poke through, but a candle close breaching the line invalidates it, so oscillator divergences are always backed by a coherent price story, not an artifact of the math.

Smart Cleanup
As new, farther-reaching divergences form, older redundant lines are automatically deleted rather than left cluttering the chart — so you're always looking at the most current, most meaningful connection.

Regular + Hidden Divergence, Fully Customizable
Both divergence types get independent color, line style, line width, and an option to project the divergence line directly onto the price chart — useful for visually confirming what the oscillator is picking up on.

Two Layers of Crossing Signals

Standard Crossing Signals fire only when K and D cross deep in oversold/overbought territory — an adjustable threshold keeps these meaningful instead of firing on every minor wiggle.
Divergence Follow-Through Signals are a second, independent signal type that only fires when a K/D cross happens within a few bars after a divergence — a way to catch the moment a spotted divergence actually starts playing out, with its own threshold, its own bar-window, and its own colors.

Money Flow, Redesigned
A gradient-shaded Money Flow ribbon fades smoothly to the zero line instead of using a flat fill, giving a cleaner read on bullish/bearish pressure at a glance.

Fully Open Customization
Overbought/Oversold lines, two fully custom adjustable reference lines, K/D colors, the fill between them, and every signal color are exposed as inputs — build the exact visual language that works for you.

Alerts for Everything That Matters
Regular and Hidden Divergence (bullish and bearish), a combined "Any Divergence" alert, both signal layers individually and combined, plus a Money Flow zero-cross alert — all wired up and ready to go straight from TradingView's alert dialog.
Nota Keluaran
Stoch — Major Update: New Signal Layer, PPO Divergence, and Spectrum Coloring

This update adds three substantial new capabilities on top of the existing structural divergence engine:

Trend Signals (New)
A third signal layer built around %K crossing a fixed threshold (default 20/80) while price sits on the correct side of its 200 EMA — a classic trend-filtered stochastic entry. Fires as a background wash on the oscillator pane, with independently colorable Buy/Sell states, and wired up to real TradingView alerts you can set directly from the alert dialog.

Percentile Rank Line + Its Own Divergence Engine (New)
A Laguerre-filtered PPO percentile-rank oscillator now runs alongside K/D, scaled to sit naturally in the same pane. It gets the exact same structural divergence detection as the main Stochastic — outer-envelope pivot validation, price-close verification, and automatic cleanup of superseded lines — as a fully independent, optional layer with its own Regular/Hidden toggles.

Spectrum Coloring for %K (New)
%K can now render as a five-stop color gradient across its full range instead of a flat color, giving an at-a-glance sense of exactly where in the 0–100 range the line currently sits, without needing to check the value.

Background Signal (New)
An optional, simple background wash showing whether %K is above or below %D at a glance — useful as a lightweight visual trend cue independent of the crossing signals.

Divergence Signal Marker Cleanup (New)
Follow-up crossing signals that fire shortly after a divergence now get cleaned up automatically if the divergence line they belonged to is later superseded by a newer, better one — keeping the chart from accumulating orphaned markers tied to lines that no longer exist.

Show/Hide Toggles Everywhere
Money Flow and the K/D Fill can each now be fully hidden with a single toggle, alongside all the existing per-feature toggles, for a cleaner pane when you only want a subset of what's on offer.

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.