OPEN-SOURCE SCRIPT
Stochastic MAs+ (K Logit Bands)

Below is a ready-to-paste **English TradingView publish description** that is detailed enough to satisfy the “Originality & usefulness” and “Description” house-rule expectations. It explains **what is original**, **why the components are combined**, **how they work together**, and **how to use it**, including practical presets and cautions.
---
## Title
**Stochastic MAs+ (K Logit Bands) — Extreme-Zone Reversion with Adaptive Percentile Bands**
## Overview
This script is a **Stochastic-based extreme-zone tool** designed for traders who want signals that occur **near statistically-defined extremes**, while reducing noise and overtrading.
It combines three ideas into one coherent workflow:
1. **Stochastic %K/%D with selectable smoothing MAs** (EMA/ZEMA/SMA/KAMA)
2. **Adaptive Logit Percentile Bands** computed **on %K** (not price) to define “extreme” zones dynamically
3. A **two-step signal workflow** (Touch → Re-entry → First K/D Cross) with **cooldown + invalidation rules** to suppress repeated signals in choppy markets
This is not a “mashup for convenience.” The logit-percentile bands and the signal state-machine are explicitly built to **solve a common Stochastic problem**: fixed 20/80 levels are often too generic, and raw K/D crosses can fire repeatedly in ranges. The components here work together to make Stochastic extremes more **context-aware** and signals more **selective**.
---
## What makes it original / useful
### 1) Dynamic extremes based on the oscillator’s own distribution
Instead of using fixed 20/80, the script builds **percentile-based bands on transformed %K values**:
* **Logit transform** is used to expand sensitivity near 0 and 100 (where Stochastic tends to compress).
* A rolling buffer stores recent transformed values.
* **Percentiles** (e.g., 15% / 85%) define adaptive low/high bands that respond to changing volatility regimes.
Result: “Extreme” zones are **relative to recent market behavior**, which is often more practical than static thresholds.
### 2) A structured signal process to reduce overtrading
Classic Stochastic crossovers can spam signals. This script uses a **state-based trigger**:
**Long logic**
1. %K drops below the **adaptive low band** (touch/arm)
2. %K re-enters above the low band (re-entry)
3. The first bullish crossover occurs (K crosses above D) while K remains below the mid-band
**Short logic** is symmetrical.
Then it adds:
* **Cooldown**: prevents clustered entries during noisy periods
* **Max wait**: invalidates old setups if confirmation takes too long
* **Mid-band invalidation**: if K moves too far (crosses mid), the setup is considered late and discarded
This turns Stochastic into a **controlled mean-reversion trigger** rather than an always-on crossover machine.
---
## How it works (plain-language)
### A) Stochastic with selectable smoothing (MAK/MAD)
* `%K` is computed from the standard Stochastic formula, then smoothed with your chosen MA.
* `%D` is computed by smoothing `%K` with a chosen MA.
**MA options**
* **EMA**: baseline responsive smoothing
* **ZEMA**: reduced lag (faster reactions)
* **SMA**: heavier smoothing (less noise)
* **KAMA**: adaptive smoothing (reacts faster when price moves, slower in noise)
### B) K-based Logit Percentile Bands
The script builds bands from **%K**, not from price:
* Convert K into logit space → store in rolling buffer
* Compute low/high percentiles in logit space
* Convert back to 0–100 space with logistic function
* Produce: **kLo / kHi / kMid**
This keeps the bands stable and meaningful even when volatility changes.
### C) Signal state-machine
* **Touch**: K enters extreme zone
* **Re-entry**: K exits the extreme zone
* **Trigger**: first K/D cross after re-entry, while still in the “early” half of the band (before mid)
The idea is to catch reversals **early**, but not on the very first noisy bounce.
---
## How to use
### 1) Baseline setup (recommended starting point)
These defaults are already aligned with the script’s intent:
* Stoch: **21 / 3 / 7**
* Bands: **bandLen 200**, **low/high 0.15/0.85**, **logitGain 1.0**
* Signals: **cooldown 8**, **maxWait 24**, **Use D Direction Confirm ON**
This typically produces fewer, more selective signals than traditional 14/3/3 style settings.
### 2) Interpreting the plots
* **%K (purple)** and **%D (yellow)** are the smoothed oscillator lines.
* **kLo / kHi / kMid** are the adaptive bands.
* Labels:
* **“L”** appears near the low band when a long setup completes
* **“S”** appears near the high band when a short setup completes
### 3) Practical trading workflow
* Prefer using signals as **timing cues**, not as a complete strategy by themselves.
* Many traders combine this with:
* a trend filter (e.g., EMA200 direction)
* a volatility filter (avoid low-vol chop)
* or higher timeframe confirmation
The script is designed to give **high-quality entry timing near extremes**, but you still need a trade plan for exits and risk management.
---
## Tuning guide (fast)
### Want signals closer to extremes (more selective)?
* Decrease / increase percentiles:
* lowPct **0.12** and highPct **0.88**
* Increase logitGain slightly:
* logitGain **1.1–1.2**
* Increase cooldown:
* cooldown **10–14**
### Want earlier signals (faster confirmations)?
* Use faster MA for %D (or reduce periodD):
* maD = **ZEMA** (or EMA)
* Reduce cooldown a bit:
* cooldown **5–8**
### Getting too many signals in ranges?
* Increase periodK to reduce chop:
* periodK **34**
* Increase cooldown
* Keep D confirm enabled
---
## Strengths
* **Adaptive extreme zones**: bands adjust to changing regimes (better context than static 20/80)
* **Reduced noise**: the Touch→Re-entry→Cross structure avoids many “random” crosses
* **Configurable smoothing**: lets you tune response vs stability via MA type
* **Risk-friendly by design**: cooldown + invalidation reduce repeated entries during chop
## Limitations
* **Not a full strategy**: no position management, take-profit/stop rules, or trend filter included
* **Mean-reversion bias**: in strong trends, Stochastic can stay overbought/oversold for long periods
* **Band buffer needs history**: percentile bands are more reliable after enough bars have accumulated (bandLen)
---
## Notes on repainting / confirmations
* The percentile band buffer uses **confirmed bars** (optional) to avoid unstable band updates during an incomplete candle.
* Signal labels are plotted when the full signal conditions are met (you can enforce confirmed-bar signals via settings).
---
## Suggested disclaimer (TradingView-friendly)
This indicator is for research and educational purposes and does not constitute financial advice. Always test settings on your market/timeframe and use proper risk management.
---
## Title
**Stochastic MAs+ (K Logit Bands) — Extreme-Zone Reversion with Adaptive Percentile Bands**
## Overview
This script is a **Stochastic-based extreme-zone tool** designed for traders who want signals that occur **near statistically-defined extremes**, while reducing noise and overtrading.
It combines three ideas into one coherent workflow:
1. **Stochastic %K/%D with selectable smoothing MAs** (EMA/ZEMA/SMA/KAMA)
2. **Adaptive Logit Percentile Bands** computed **on %K** (not price) to define “extreme” zones dynamically
3. A **two-step signal workflow** (Touch → Re-entry → First K/D Cross) with **cooldown + invalidation rules** to suppress repeated signals in choppy markets
This is not a “mashup for convenience.” The logit-percentile bands and the signal state-machine are explicitly built to **solve a common Stochastic problem**: fixed 20/80 levels are often too generic, and raw K/D crosses can fire repeatedly in ranges. The components here work together to make Stochastic extremes more **context-aware** and signals more **selective**.
---
## What makes it original / useful
### 1) Dynamic extremes based on the oscillator’s own distribution
Instead of using fixed 20/80, the script builds **percentile-based bands on transformed %K values**:
* **Logit transform** is used to expand sensitivity near 0 and 100 (where Stochastic tends to compress).
* A rolling buffer stores recent transformed values.
* **Percentiles** (e.g., 15% / 85%) define adaptive low/high bands that respond to changing volatility regimes.
Result: “Extreme” zones are **relative to recent market behavior**, which is often more practical than static thresholds.
### 2) A structured signal process to reduce overtrading
Classic Stochastic crossovers can spam signals. This script uses a **state-based trigger**:
**Long logic**
1. %K drops below the **adaptive low band** (touch/arm)
2. %K re-enters above the low band (re-entry)
3. The first bullish crossover occurs (K crosses above D) while K remains below the mid-band
**Short logic** is symmetrical.
Then it adds:
* **Cooldown**: prevents clustered entries during noisy periods
* **Max wait**: invalidates old setups if confirmation takes too long
* **Mid-band invalidation**: if K moves too far (crosses mid), the setup is considered late and discarded
This turns Stochastic into a **controlled mean-reversion trigger** rather than an always-on crossover machine.
---
## How it works (plain-language)
### A) Stochastic with selectable smoothing (MAK/MAD)
* `%K` is computed from the standard Stochastic formula, then smoothed with your chosen MA.
* `%D` is computed by smoothing `%K` with a chosen MA.
**MA options**
* **EMA**: baseline responsive smoothing
* **ZEMA**: reduced lag (faster reactions)
* **SMA**: heavier smoothing (less noise)
* **KAMA**: adaptive smoothing (reacts faster when price moves, slower in noise)
### B) K-based Logit Percentile Bands
The script builds bands from **%K**, not from price:
* Convert K into logit space → store in rolling buffer
* Compute low/high percentiles in logit space
* Convert back to 0–100 space with logistic function
* Produce: **kLo / kHi / kMid**
This keeps the bands stable and meaningful even when volatility changes.
### C) Signal state-machine
* **Touch**: K enters extreme zone
* **Re-entry**: K exits the extreme zone
* **Trigger**: first K/D cross after re-entry, while still in the “early” half of the band (before mid)
The idea is to catch reversals **early**, but not on the very first noisy bounce.
---
## How to use
### 1) Baseline setup (recommended starting point)
These defaults are already aligned with the script’s intent:
* Stoch: **21 / 3 / 7**
* Bands: **bandLen 200**, **low/high 0.15/0.85**, **logitGain 1.0**
* Signals: **cooldown 8**, **maxWait 24**, **Use D Direction Confirm ON**
This typically produces fewer, more selective signals than traditional 14/3/3 style settings.
### 2) Interpreting the plots
* **%K (purple)** and **%D (yellow)** are the smoothed oscillator lines.
* **kLo / kHi / kMid** are the adaptive bands.
* Labels:
* **“L”** appears near the low band when a long setup completes
* **“S”** appears near the high band when a short setup completes
### 3) Practical trading workflow
* Prefer using signals as **timing cues**, not as a complete strategy by themselves.
* Many traders combine this with:
* a trend filter (e.g., EMA200 direction)
* a volatility filter (avoid low-vol chop)
* or higher timeframe confirmation
The script is designed to give **high-quality entry timing near extremes**, but you still need a trade plan for exits and risk management.
---
## Tuning guide (fast)
### Want signals closer to extremes (more selective)?
* Decrease / increase percentiles:
* lowPct **0.12** and highPct **0.88**
* Increase logitGain slightly:
* logitGain **1.1–1.2**
* Increase cooldown:
* cooldown **10–14**
### Want earlier signals (faster confirmations)?
* Use faster MA for %D (or reduce periodD):
* maD = **ZEMA** (or EMA)
* Reduce cooldown a bit:
* cooldown **5–8**
### Getting too many signals in ranges?
* Increase periodK to reduce chop:
* periodK **34**
* Increase cooldown
* Keep D confirm enabled
---
## Strengths
* **Adaptive extreme zones**: bands adjust to changing regimes (better context than static 20/80)
* **Reduced noise**: the Touch→Re-entry→Cross structure avoids many “random” crosses
* **Configurable smoothing**: lets you tune response vs stability via MA type
* **Risk-friendly by design**: cooldown + invalidation reduce repeated entries during chop
## Limitations
* **Not a full strategy**: no position management, take-profit/stop rules, or trend filter included
* **Mean-reversion bias**: in strong trends, Stochastic can stay overbought/oversold for long periods
* **Band buffer needs history**: percentile bands are more reliable after enough bars have accumulated (bandLen)
---
## Notes on repainting / confirmations
* The percentile band buffer uses **confirmed bars** (optional) to avoid unstable band updates during an incomplete candle.
* Signal labels are plotted when the full signal conditions are met (you can enforce confirmed-bar signals via settings).
---
## Suggested disclaimer (TradingView-friendly)
This indicator is for research and educational purposes and does not constitute financial advice. Always test settings on your market/timeframe and use proper risk management.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.