OPEN-SOURCE SCRIPT
Adaptive Stochastic+ [MAB]

Adaptive Stochastic+ is a self-optimizing momentum oscillator that dynamically selects the most effective stochastic settings
Instead of relying on fixed %K periods and smoothing values, this indicator continuously evaluates multiple configurations and automatically selects the ones that have been performing best on recent price action — delivering a stochastic oscillator that adapts to changing market conditions and momentum cycles.
🔶 HOW IT WORKS
Traditional Stochastic indicators use fixed parameters, which can become unreliable as market conditions shift. Adaptive Stochastic+ solves this by running two parallel optimization processes:
K Period Selection → Tests multiple %K lengths to determine the most responsive momentum structure
Smoothing Selection → Evaluates different smoothing levels to balance noise and stability
Each configuration is scored using an exponential performance model that tracks whether momentum is consistently aligning with price movement.
On every bar:
The best-performing %K period is selected
The best-performing smoothing level is selected
Both are combined to form a final adaptive %K line
A %D signal line is derived using standard smoothing
This creates a stochastic oscillator that continuously adjusts its sensitivity based on current market behavior.
🔶 USAGE
🔹 Momentum Structure
%K Line — Primary adaptive momentum line
%D Line — Smoothed signal line used for confirmation
Green %K — Oversold region (potential upward momentum)
Red %K — Overbought region (potential downward momentum)
Gray %K — Neutral zone
🔹 Key Levels
Overbought Zone — Indicates strong upward momentum that may be overextended
Oversold Zone — Indicates strong downward momentum that may be exhausted
Midline (50) — Separates bullish and bearish momentum bias
🔹 Trade Signals
Green crossover — Bullish signal. %K crosses above %D below the midline, indicating potential upside momentum
Red crossover — Bearish signal. %K crosses below %D above the midline, indicating potential downside momentum
Because both %K period and smoothing are dynamically selected, signals reflect momentum conditions optimized for recent price action — not static parameters.
🔶 SETTINGS
🔹 Adaptive Engine
Perf EMA Length — Controls how quickly the performance scoring adapts to new conditions. Lower values react faster; higher values are smoother.
🔹 Stochastic Settings
D Smoothing — Fixed smoothing applied to the final %K to create the %D line
🔹 Levels
Overbought Level — Upper threshold for momentum extremes
Oversold Level — Lower threshold for momentum extremes
🔶 NOTES
Suitable for all markets and timeframes.
Works best as a momentum timing and reversal confirmation tool.
Adaptive parameter selection helps reduce false signals in choppy markets while staying responsive in trends.
Can be combined with trend indicators for higher-probability setups.
Past performance of any selected configuration does not guarantee future results — always apply proper risk management.
Instead of relying on fixed %K periods and smoothing values, this indicator continuously evaluates multiple configurations and automatically selects the ones that have been performing best on recent price action — delivering a stochastic oscillator that adapts to changing market conditions and momentum cycles.
🔶 HOW IT WORKS
Traditional Stochastic indicators use fixed parameters, which can become unreliable as market conditions shift. Adaptive Stochastic+ solves this by running two parallel optimization processes:
K Period Selection → Tests multiple %K lengths to determine the most responsive momentum structure
Smoothing Selection → Evaluates different smoothing levels to balance noise and stability
Each configuration is scored using an exponential performance model that tracks whether momentum is consistently aligning with price movement.
On every bar:
The best-performing %K period is selected
The best-performing smoothing level is selected
Both are combined to form a final adaptive %K line
A %D signal line is derived using standard smoothing
This creates a stochastic oscillator that continuously adjusts its sensitivity based on current market behavior.
🔶 USAGE
🔹 Momentum Structure
%K Line — Primary adaptive momentum line
%D Line — Smoothed signal line used for confirmation
Green %K — Oversold region (potential upward momentum)
Red %K — Overbought region (potential downward momentum)
Gray %K — Neutral zone
🔹 Key Levels
Overbought Zone — Indicates strong upward momentum that may be overextended
Oversold Zone — Indicates strong downward momentum that may be exhausted
Midline (50) — Separates bullish and bearish momentum bias
🔹 Trade Signals
Green crossover — Bullish signal. %K crosses above %D below the midline, indicating potential upside momentum
Red crossover — Bearish signal. %K crosses below %D above the midline, indicating potential downside momentum
Because both %K period and smoothing are dynamically selected, signals reflect momentum conditions optimized for recent price action — not static parameters.
🔶 SETTINGS
🔹 Adaptive Engine
Perf EMA Length — Controls how quickly the performance scoring adapts to new conditions. Lower values react faster; higher values are smoother.
🔹 Stochastic Settings
D Smoothing — Fixed smoothing applied to the final %K to create the %D line
🔹 Levels
Overbought Level — Upper threshold for momentum extremes
Oversold Level — Lower threshold for momentum extremes
🔶 NOTES
Suitable for all markets and timeframes.
Works best as a momentum timing and reversal confirmation tool.
Adaptive parameter selection helps reduce false signals in choppy markets while staying responsive in trends.
Can be combined with trend indicators for higher-probability setups.
Past performance of any selected configuration does not guarantee future results — always apply proper risk management.
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.
Pine Script Developer • Market Analysis
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.
Pine Script Developer • Market Analysis
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.