# Stochastic

Use the [shared role, Reverse and timing rules](../05-signal-passports.md). Raw K expresses `100*(close−lowest_low)/(highest_high−lowest_low)` over `k_p` bars. The selected K and D lines are smoothed with simple moving averages: `k_s` controls K smoothing; `d_s` controls D. The comparisons below use these smoothed lines, not raw K.

The three periods are integers 2…50; defaults are 14/3/3. A zero high−low range does not justify inventing a crossing; initialization and undefined-value behaviour are outside the finite-value predicates.

## Entry — stochastic.entry

K1<D1 and K0>=D0 gives L; K1>D1 and K0<=D0 gives S; otherwise N. This variant does not require either line to be overbought or oversold. A crossing and a line being in an extreme region are separate conditions.

## Filter — stochastic.filter

`STOCH_CHANNEL_PRICE_LIMIT` adds integer thresholds up/low 5…95, with up>low, and `ft`. Defaults are up=80, low=20, BD.

If **both** K0>=up and D0>=up, give IL. Otherwise, if **both** K0<=low and D0<=low, give IS. Otherwise BD gives AA and BHL gives N. One line in an extreme region is insufficient. Equality is included for both threshold comparisons.

## Exit — stochastic.exit

Use the K/D crossing and shared cba rules, including the distinct own-side AVG action. The channel filter is a separate state rule and does not replace the exit crossing.

## Definition coverage and observed controls

The controls below identify this dated schema. Their exact labels, value types and context overrides are in the catalogue. Any omitted standard selector must not be added manually.

- `stochastic.entry` — `MAIN` / `STOCH`. Semantics: **Entry — stochastic.entry**. Fields: `ss`, `Is`, `ct`, `at`, `rs`, `k_p`, `k_s`, `d_s`. timeframe: ID-specific list; default 1m; candles: DEFAULT/HEIKEN_ASHI; default DEFAULT; calculation: CL/CR; default CL; Reverse: available; default false.
- `stochastic.exit` — `CLOSE_BY` / `STOCH`. Semantics: **Exit — stochastic.exit**. Fields: `ss`, `Is`, `ct`, `at`, `rs`, `cba`, `k_p`, `k_s`, `d_s`. timeframe: ID-specific list; default 1m; candles: DEFAULT/HEIKEN_ASHI; default DEFAULT; calculation: CL/CR; default CL; Reverse: available; default false.
- `stochastic.filter` — `PRICE_LIMIT` / `STOCH_CHANNEL_PRICE_LIMIT`. Semantics: **Filter — stochastic.filter**. Fields: `ss`, `Is`, `ct`, `at`, `rs`, `pla`, `k_p`, `k_s`, `d_s`, `up`, `low`, `ft`. timeframe: ID-specific list; default 1m; candles: DEFAULT/HEIKEN_ASHI; default DEFAULT; calculation: CL/CR; default CL; Reverse: available; default false.
