Indicator · Pine Script v5 · On the chart

Stoch Price Envelope

by teshmi9z-beep

An overlay that converts a long-period stochastic reading back into price levels.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code36
Settings5inputs
LicenceMIT
Last update2 days ago28 Oct 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

36 lines of Pine Script v5 from src/indicators/custom/stochPriceEnvelope.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

stochPriceEnvelope.pine
//@version=5
indicator("Stoch Price Envelope [1-99] - No BB", overlay=true)

// --- PARAMÈTRES ---
k_period = input.int(200, "Période (Mémoire 200)", minval=1)
smooth_k = input.int(3, "Lissage K", minval=1)
d_period = input.int(200, "Période D (Signal)", minval=1)
level_high = input.float(99.0, "Niveau Haut (%)")
level_low = input.float(1.0, "Niveau Bas (%)")

// --- CALCULS DES BORNES (HH / LL) ---
hh = ta.highest(high, k_period)
ll = ta.lowest(low, k_period)
range_price = hh - ll

// --- CALCUL STOCHASTIQUE CLASSIQUE (INTERNE) ---
raw_k = 100 * (close - ll) / range_price
smoothed_k = ta.sma(raw_k, smooth_k)
d_signal = ta.sma(smoothed_k, d_period)

// --- REVERSE ENGINEERING (PROJECTION SUR LE PRIX) ---
price_99 = (level_high / 100) * range_price + ll
price_01 = (level_low / 100) * range_price + ll
price_mid = (50.0 / 100) * range_price + ll
price_signal = (d_signal / 100) * range_price + ll

// --- DÉTECTION DU MODE "ESCALIER" (TENDANCE) ---
// Si le plus haut ou le plus bas historique des 200 bougies bouge, on est en tendance
is_breaking_up = hh > hh[1]
is_breaking_down = ll < ll[1]

// --- AFFICHAGE DES LIGNES ---
plot(price_99, "Plafond (99%)", color=color.new(color.red, 0), linewidth=2)
plot(price_01, "Plancher (1%)", color=color.new(color.lime, 0), linewidth=2)
plot(price_mid, "Milieu (50%)", color=color.new(color.orange, 50), linewidth=1, style=plot.style_stepline)
plot(price_signal, "Signal Stoch", color=color.new(color.orange, 0), linewidth=2)

Overview

Using the highest high and lowest low over a lookback window of 200 bars by default, it plots a ceiling at the high stochastic level, a floor at the low level, a midpoint, and a line showing where a smoothed stochastic signal sits in price terms. The upper and lower percent levels, smoothing and signal period are adjustable. It draws on the price chart.

Details

Published by

teshmi9z-beep on GitHub

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

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.

Settings

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

SettingTypeDefaultVariable
Période (Mémoire 200)int200k_period
Lissage Kint3smooth_k
Période D (Signal)int200d_period
Niveau Haut (%)float99.0level_high
Niveau Bas (%)float1.0level_low
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

PivotHighLow

by Alorse
330 stars

This indicator calculates pivot high and pivot low points on the price chart based on configurable left and right bar counts. Confirmed pivot highs and lows are plotted with negative bar offsets directly on the price chart using line and cross styles. Addition

Indicator v4 Support & resistanceOscillators & momentum Repaints
Updated 2 months ago · None stated GitHub repository of PivotHighLow
114 stars

This indicator calculates key support and resistance levels by analyzing the first and second momentum derivatives of a Double Exponential Moving Average (DEMA). When the second derivative (momentum of momentum) crosses zero, it identifies local turning points

Indicator v4 Support & resistanceOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Support and Resistance Levels

Moon Dev Lunar Sniper

by moondevonyt
92 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 2 months ago · Custom licence GitHub repository of Moon Dev Lunar Sniper
23 stars

This indicator collection calculates and plots previous daily high and low price levels on the chart to identify potential supply and demand zones. It includes real-time intraday high and low calculations, RSI divergence detection across a customizable period

Indicator v4 Support & resistanceDivergence
Updated 3 years ago · None stated GitHub repository of Daily High and Low Strategy
14 stars

Self-Aware Trend System calculates volatility-adaptive ATR trailing bands using a Trend Quality Index engine that evaluates market efficiency, momentum persistence, and structural pivots. It plots adaptive trend bands and character-flip trend signals directly

Indicator v6 TrendVolatility & bands
Updated 3 weeks ago · MIT GitHub repository of Self-Aware Trend System [WillyAlgoTrader]

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