Indicator · Pine Script v6 · Own pane

LG9k StochSlow Zone-Cross (tiered)

by theonetrade

This indicator calculates a Slow Stochastic oscillator and plots tiered zone-cross signals in a separate pane.

View on GitHub

GitHub stars34on the repository
Pine versionv6current
Lines of code227
Settings20inputs
LicenceMIT
Last update2 weeks ago8 Nov 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

227 lines of Pine Script v6 from assets/indicator/bit-exact/lg9k_stochslow_zone_cross_tiered_1jtVJlku.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

lg9k_stochslow_zone_cross_tiered_1jtVJlku.pine
//@version=6
// LG9k — ToS StochasticSlow zone-cross, TIERED + EXTREME (Bill 2026-09-17)
//
// Four tiers on one trigger, drawn always, alerting selectively:
//
//   EXTREME  cross out of a DEEP zone -- SlowK <= 5 for a long, >= 95 for a short.
//            Its own loud alert. Not trend-gated (see below).
//   A        zone cross AT a Mancini major (within `prox`). Large bright triangle.
//            Also requires trend alignment IF the trend gate is on (it defaults off).
//   B        zone cross that passed the enabled gates but is NOT near a major.
//            Small, darker triangle -- same event, lower rank.
//   C        zone cross that failed the trend gate (only reachable with that gate
//            on). Tiny blue-grey x. Never alerts.
//
// Gates:
//   EXCURSION  SlowK must climb back out of the zone before the same side can fire
//              again. On the overnight /ES chart of 2026-09-17 one elevated swing
//              produced four bearish arrows (02:30/02:45/03:10/03:35); this
//              collapses runs like that. Measured on the real bars of that window
//              it removed 3 of 16 -- helpful, not a cure.
//   TREND      8 EMA + PSAR, mirroring `require_trend=True` in the live Python
//              alerter. NOTE: on that same 16-signal window it passed 0, and only
//              2 of 28 across all available 3m history. That is structural, not a
//              bug -- a zone cross happens AT a local extreme, which is by
//              definition the wrong side of the 8 EMA. The trend gate and this
//              signal are anti-correlated by construction, which is why EXTREME
//              deliberately bypasses it.
//   LEVEL      within `prox` points of a Mancini major (majors are regenerated
//              daily into pine/mancini_levels.pine -- paste them below).
//
// ══ WHAT THE DATA SAYS — READ BEFORE TRADING THIS ════════════════════════════
// Measured on 4,694 zone crosses over 9 months of native 5m /ES bars, exits
// forward-walked from each entry (stop 1.0xATR, ties scored as stops):
//
//     target    breakeven    NORMAL(<=20/>=80)    EXTREME(<=5/>=95)
//      0.5R       66.7%          65.6%                65.6%
//      1.0R       50.0%          49.7%                51.1%
//      1.5R       40.0%          40.1%                40.7%
//      2.0R       33.3%          34.3%                35.1%
//      3.0R       25.0%          27.3%                29.4%
//
// The win rate tracks the geometric breakeven line within ~1pp at every target,
// for both depths. That is the signature of a signal carrying NO directional
// information -- the strike rate is set by the reward:risk you pick, not by the
// setup. Depth does not help (EXTREME avgR +0.012 on n=659). Level confluence
// looked strong at n<30 but was a period artifact. The live paper book agrees:
// 170 tracked trades, -1,011 points, and star rank did not rank.
//
// So this script is a SPAM FILTER and a RANKING FOR THE EYE. It is not an edge,
// and nothing in it should be sized off without a separate, positive study.
// ═════════════════════════════════════════════════════════════════════════════

indicator("LG9k StochSlow Zone-Cross (tiered)", overlay = false, precision = 2, max_labels_count = 500)

// ── Stochastic (ToS StochasticSlow 3-stage: rawK -> slowing -> FullK -> FullD) ─
grpS = "Stochastic (ToS StochasticSlow)"
kPeriod  = input.int(10,  "K period",         group = grpS, minval = 1)
dPeriod  = input.int(3,   "D period",         group = grpS, minval = 1)
slowing  = input.int(3,   "Slowing (smooth)", group = grpS, minval = 1)
obLevel  = input.float(80, "Overbought 1",    group = grpS, inline = "ob1")
osLevel  = input.float(20, "Oversold 1",      group = grpS, inline = "os1")
zoneBars = input.int(5, "Cross counts if K was in the zone within N bars", group = grpS, minval = 1)

hh  = ta.highest(high, kPeriod)
ll  = ta.lowest(low, kPeriod)
rng = hh - ll
rawK  = rng == 0 ? 50.0 : 100.0 * (close - ll) / rng
fullK = ta.sma(rawK, slowing)
fullD = ta.sma(fullK, dPeriod)

// ── EXTREME ───────────────────────────────────────────────────────────────────
grpE = "EXTREME tier"
useExtreme   = input.bool(true, "Enable EXTREME tier", group = grpE)
// Second OB/OS pair (Bill 2026-09-17). These live in INPUTS, not Style, on purpose:
// an hline whose value box is editable in the Style tab must be a Pine CONSTANT, and
// a constant is invisible to the script -- so editing 95 -> 97 there would MOVE THE
// LINE while the alerts kept firing at 95. A band that disagrees with its own alert
// is worse than no band. Driven from here, the line and the alert cannot drift.
extremeOb    = input.float(95, "Overbought 2 (EXTREME)", group = grpE, inline = "ob2")
extremeOs    = input.float(5,  "Oversold 2 (EXTREME)",   group = grpE, inline = "os2")
extremeTrend = input.bool(false, "EXTREME must also pass the trend gate", group = grpE, tooltip = "Off by default: the trend gate passed 0 of 16 signals on the 2026-09-17 overnight window and 2 of 28 across all 3m history, because a zone cross sits on the wrong side of the 8 EMA by construction. Turning this on will silence EXTREME almost entirely.")
extremeLevel = input.bool(false, "EXTREME must also be near a major",     group = grpE)

// ── Gates ─────────────────────────────────────────────────────────────────────
grpG = "Gates"
useExcursion = input.bool(true, "Excursion gate (one signal per zone visit)",   group = grpG)
// Default OFF (Bill 2026-09-17). With it ON, A/B need 8EMA+PSAR alignment, which
// passed 0 of 7 signals on his overnight window and ~5% overall -- a zone cross
// sits on the wrong side of the 8 EMA by construction -- so every non-EXTREME
// signal collapsed into tier C and the A/B arrows never appeared. With it OFF,
// tiering falls back to level proximity and actually spreads the signals out.
useTrend     = input.bool(false, "Trend gate (8 EMA + PSAR) for tiers A/B",     group = grpG)
useLevel     = input.bool(true, "Level gate (near a Mancini major) for tier A", group = grpG)
emaLen       = input.int(8, "EMA length", group = grpG, minval = 1)
showCounter  = input.bool(true, "Show tier counter", group = grpG)
showC        = input.bool(true, "Draw tier C (the lowest-ranked crosses)", group = grpG)
// NOTE (Bill 2026-09-17): every plot colour here is a compile-time CONSTANT on
// purpose. Pine only renders the Style-tab colour picker for constant colours --
// the moment a colour is computed from an input or a series, TradingView removes
// the picker, since the script would overwrite whatever you chose. A short-lived
// "dimRejects" input did exactly that and cost the pickers on B and C. Opacity is
// already part of the Style picker, so the input bought nothing. Do not
// reintroduce a colour that depends on an input.

ema8 = ta.ema(close, emaLen)
psar = ta.sar(0.02, 0.02, 0.2)
trendLong  = close > ema8 and psar < close
trendShort = close < ema8 and psar > close

// ── Levels + session-aware proximity ──────────────────────────────────────────
grpL = "Mancini levels"
majorsCsv  = input.string("7469,7526,7584,7604,7622,7663,7687,7695,7714,7728,7759,7782", "MAJORS (comma separated)", group = grpL)
proxRth    = input.float(8.0, "Proximity, RTH (points)",    group = grpL, step = 0.25)
proxGlobex = input.float(5.0, "Proximity, Globex (points)", group = grpL, step = 0.25)

var float[] majors = array.new_float(0)
if barstate.isfirst
    parts = str.split(str.replace_all(majorsCsv, " ", ""), ",")
    for i = 0 to array.size(parts) - 1
        v = str.tonumber(array.get(parts, i))
        if not na(v)
            array.push(majors, v)

nearestMajor(float px) =>
    float best = na
    if array.size(majors) > 0
        for i = 0 to array.size(majors) - 1
            d = math.abs(px - array.get(majors, i))
            best := na(best) or d < best ? d : best
    best

inRth     = not na(time(timeframe.period, "0930-1600:23456", "America/New_York"))
prox      = inRth ? proxRth : proxGlobex
dist      = nearestMajor(close)
nearLevel = not na(dist) and dist <= prox

// ── Signals ───────────────────────────────────────────────────────────────────
bullCross = ta.crossover(fullK, fullD)
bearCross = ta.crossunder(fullK, fullD)
kLo = ta.lowest(fullK, zoneBars)
kHi = ta.highest(fullK, zoneBars)

bullRaw = bullCross and kLo <= osLevel
bearRaw = bearCross and kHi >= obLevel
// The deep touch may be up to `zoneBars` back, so ALSO require K to still be in
// the ordinary zone as it crosses. Without this a cross at K=78.9 qualified as
// "EXTREME" because K had tagged 95 five bars (15 min on 3m) earlier -- true to
// the lookback, misleading on the chart.
bullDeep = bullCross and kLo <= extremeOs and fullK <= osLevel
bearDeep = bearCross and kHi >= extremeOb and fullK >= obLevel

// Excursion: after a signal, K must leave the zone before the same side re-arms.
var bool bullArmed = true
var bool bearArmed = true
bullSig = bullRaw and (not useExcursion or bullArmed)
bearSig = bearRaw and (not useExcursion or bearArmed)
if bullSig
    bullArmed := false
else if fullK > osLevel
    bullArmed := true
if bearSig
    bearArmed := false
else if fullK < obLevel
    bearArmed := true

trendOkL = not useTrend or trendLong
trendOkS = not useTrend or trendShort
levelOk  = not useLevel or nearLevel

// EXTREME outranks A. Its gates are independent and default to off.
xLong  = useExtreme and bullSig and bullDeep and (not extremeTrend or trendLong)  and (not extremeLevel or nearLevel)
xShort = useExtreme and bearSig and bearDeep and (not extremeTrend or trendShort) and (not extremeLevel or nearLevel)

aLong  = bullSig and not xLong  and trendOkL and levelOk
aShort = bearSig and not xShort and trendOkS and levelOk
bLong  = bullSig and not xLong  and trendOkL and not aLong
bShort = bearSig and not xShort and trendOkS and not aShort
cLong  = bullSig and not xLong  and not trendOkL
cShort = bearSig and not xShort and not trendOkS

// ── Plot ──────────────────────────────────────────────────────────────────────
plot(fullK, "SlowK", color = #26C6DA, linewidth = 2)
plot(fullD, "SlowD", color = #EF5350, linewidth = 2)
hline(obLevel, "Over Bought 1", color = color.new(color.gray, 50), linestyle = hline.style_dashed)
hline(osLevel, "Over Sold 1",   color = color.new(color.gray, 50), linestyle = hline.style_dashed)
xo = hline(extremeOb, "Over Bought 2", color = color.new(#FF1744, 40), linestyle = hline.style_dotted)
xs = hline(extremeOs, "Over Sold 2",   color = color.new(#00E676, 40), linestyle = hline.style_dotted)
fill(hline(100), xo, color = color.new(#FF1744, 88))
fill(xs, hline(0),  color = color.new(#00E676, 88))

// Everything is drawn; only EXTREME/A/B alert — so the filter stays auditable.
plotshape(xLong  ? fullK : na, "EXTREME LONG",  shape.labelup,      location.absolute, #00E676, text = "X", textcolor = color.black, size = size.normal)
plotshape(xShort ? fullK : na, "EXTREME SHORT", shape.labeldown,    location.absolute, #FF1744, text = "X", textcolor = color.white, size = size.normal)
plotshape(aLong  ? fullK : na, "A LONG",        shape.triangleup,   location.absolute, #00E676, size = size.normal)
plotshape(aShort ? fullK : na, "A SHORT",       shape.triangledown, location.absolute, #FF1744, size = size.normal)
plotshape(bLong  ? fullK : na, "B LONG",        shape.triangleup,   location.absolute, #00B85C, size = size.small)
plotshape(bShort ? fullK : na, "B SHORT",       shape.triangledown, location.absolute, #C4142F, size = size.small)
plotshape(showC and cLong  ? fullK : na, "C LONG",  shape.xcross,   location.absolute, #B0BEC5, size = size.tiny)
plotshape(showC and cShort ? fullK : na, "C SHORT", shape.xcross,   location.absolute, #B0BEC5, size = size.tiny)
bgcolor(xLong ? color.new(#00E676, 88) : xShort ? color.new(#FF1744, 88) : na, title = "EXTREME flash")

// ── Alerts (one per condition so each takes its own sound in Notifications) ───
alertcondition(xLong,          "🔥 EXTREME LONG  (K<=5)",   "EXTREME LONG {{ticker}} {{close}} — StochSlow crossed up out of <=5. Deep oversold reversal.")
alertcondition(xShort,         "🔥 EXTREME SHORT (K>=95)",  "EXTREME SHORT {{ticker}} {{close}} — StochSlow crossed down out of >=95. Deep overbought reversal.")
alertcondition(xLong or xShort, "🔥 EXTREME either way",    "EXTREME {{ticker}} {{close}} — StochSlow reversed out of a deep zone.")
alertcondition(aLong,          "A LONG  — cross AT a level",  "A LONG {{ticker}} {{close}} — stoch zone cross AT a Mancini major")
alertcondition(aShort,         "A SHORT — cross AT a level",  "A SHORT {{ticker}} {{close}} — stoch zone cross AT a Mancini major")
alertcondition(bLong,          "B LONG  — cross, no level",          "B LONG {{ticker}} {{close}} — stoch zone cross, no level nearby")
alertcondition(bShort,         "B SHORT — cross, no level",          "B SHORT {{ticker}} {{close}} — stoch zone cross, no level nearby")

// ── Diagnostics: is the filter too strict today? ──────────────────────────────
var int nX = 0
var int nA = 0
var int nB = 0
var int nC = 0
if xLong or xShort
    nX += 1
if aLong or aShort
    nA += 1
if bLong or bShort
    nB += 1
if cLong or cShort
    nC += 1
if showCounter and barstate.islast
    var label lab = na
    label.delete(lab)
    lab := label.new(bar_index, 100, str.format("EXTREME {0} · A {1} · B {2} · C {3}", nX, nA, nB, nC), style = label.style_label_left, color = color.new(color.black, 20), textcolor = color.white, size = size.small)

Overview

LG9k StochSlow Zone-Cross (tiered) ranks crosses from overbought and oversold zones into four tiers (EXTREME, A, B, and C) using zone depth, an excursion filter allowing one signal per zone visit, an optional EMA and Parabolic SAR trend gate, and proximity to user-defined major levels for RTH and Globex sessions. Inputs adjust stochastic periods, zone lookback bars, price levels, and tier visibility. Notably, the trend gate conflicts structurally with extreme crosses, acting purely as a visual filter.

Details

Published by

theonetrade on GitHub

Draws

Separate pane below the chart

Markets

Indices

Timeframes

M1-M5, M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
K periodint10kPeriod
D periodint3dPeriod
Slowing (smooth)int3slowing
Overbought 1float80obLevel
Oversold 1float20osLevel
Cross counts if K was in the zone within N barsint5zoneBars
Enable EXTREME tierbooltrueuseExtreme
Overbought 2 (EXTREME)float95extremeOb
Oversold 2 (EXTREME)float5extremeOs
EXTREME must also pass the trend gateboolfalseextremeTrend
EXTREME must also be near a majorboolfalseextremeLevel
Excursion gate (one signal per zone visit)booltrueuseExcursion
Show all 20 settings
SettingTypeDefaultVariable
Trend gate (8 EMA + PSAR) for tiers A/BboolfalseuseTrend
Level gate (near a Mancini major) for tier AbooltrueuseLevel
EMA lengthint8emaLen
Show tier counterbooltrueshowCounter
Draw tier C (the lowest-ranked crosses)booltrueshowC
MAJORS (comma separated)string7469,7526,7584,7604,7622,7663,7687,7695,7714,7728,7759,7782majorsCsv
Proximity, RTH (points)float8.0proxRth
Proximity, Globex (points)float5.0proxGlobex
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

3 stars

This indicator calculates and plots the NYSE Cumulative Tick Index as colored candles in a separate pane, with green indicating upward tick trends and red downward trends. Overbought and oversold zones are marked using smoothed averages of high and low tick va

Indicator v5 Oscillators & momentumVolatility & bands
Updated 6 months ago · None stated GitHub repository of CSW Tick Internals

SPY 0DTE Scalper - 15min

by chris-c-thomas
13 stars

This intraday overlay establishes directional bias and high-conviction swing setups for SPY on the 15-minute timeframe. It computes a weighted confluence score combining an EMA ribbon, a 50 EMA anchor, session VWAP bands, RSI divergence, ADX, TTM Squeeze, cand

Indicator v6 TrendOscillators & momentum
Updated 7 months ago · MIT GitHub repository of SPY 0DTE Scalper - 15min
6 stars

The ORB + Fib + MACD Indicator combines Opening Range Breakout mechanics with Fibonacci retracement levels and MACD momentum filtering. It determines the high and low bounds of a user-defined initial session window, projects Fibonacci entry zones, and calculat

Indicator v5 Sessions & timeSupport & resistance
Updated 8 months ago · None stated GitHub repository of ORB + Fib + MACD Indicator

MTF RSI Signals

by iyoshikawa
1 stars

This indicator plots multi-timeframe RSI signals on the price chart. It calculates a smoothed RSI using short and long periods with EMA smoothing, then applies a Stoch filter for direction changes. Signals trigger on crossovers and levels, combined with ADX tr

Indicator v5 Oscillators & momentumTrend Repaints
Updated 5 months ago · None stated GitHub repository of MTF RSI Signals

Polish Setup Indicator

by GreyssonEnterprises
1 stars

Plots a smoothed moving average stack alongside detected W and M patterns, RSI momentum filtering, and Fibonacci-style extension targets. The indicator evaluates trend alignment across fast, medium, and slow SMMAs, scans recent price bars for double top or bot

Indicator v5 Moving averagesOscillators & momentum
Updated 3 months ago · MIT GitHub repository of Polish Setup Indicator

More Oscillators & momentum scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers