Strategy · Pine Script v6 · On the chart

PF probe 105 - volty expansion close

by pineforge-4pass· code credited to PineForge contributors 2026

This strategy draws Bollinger-style bands on the price chart using ta.sma and ta.stdev of close.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code56
Settings2inputs
LicenceApache-2.0
Last update5 days ago23 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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

56 lines of Pine Script v6 from validation/ta-stdev-sma-expansion-break-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// PF probe 105 — volatility-expansion close break
// Clean-room: written from validation goal, not from source.
//
// Purpose: exercises the rolling `ta.stdev(close, 20)` pair with
// `ta.sma(close, 20)` as a Bollinger-style expansion band, then
// fires entries when the close itself breaks past the upper or
// lower band. Two engine surfaces are pinned:
//   (1) `ta.stdev` denominator convention — sample (n-1) vs
//       population (n) divergence shifts the band slightly and
//       flips a few borderline-bar break events.
//   (2) Strict close-vs-band comparison ordering relative to the
//       band's own update on the same bar (the band is computed
//       from the same close that's being compared to it).
//
// Validation goal: bit-exact trade list against TradingView's broker
// emulator on the reference 15m feed. Pass = every break-driven
// entry fires on the same bar TradingView places it.
//
// TV setup: 15m chart, ETH-USDT-USDT (Binance USDT-M Perpetual). Full
// window matching corpus/data/ohlcv_ETH-USDT-USDT_15m.csv. Strategy
// properties: leave defaults from script header. Export "List of
// trades" → tv_trades.csv.
//@version=6
strategy("PF probe 105 - volty expansion close", shorttitle="PF_p105_VEXP",
     overlay=true, initial_capital=1000000,
     commission_type=strategy.commission.percent, commission_value=0,
     slippage=0, default_qty_type=strategy.fixed, default_qty_value=1,
     pyramiding=1, process_orders_on_close=false)

// ---- inputs --------------------------------------------------------
int   i_len  = input.int(20,  "Baseline / stdev length", minval=2,   maxval=200)
float i_mult = input.float(2.0,"Expansion multiple",     minval=0.5, maxval=10.0, step=0.1)

// ---- baseline + expansion bands -----------------------------------
float baseline = ta.sma(close,  i_len)
float vol      = ta.stdev(close,i_len)
float upper    = baseline + vol * i_mult
float lower    = baseline - vol * i_mult

// ---- close-vs-band breakout entries -------------------------------
bool bull_break = close > upper
bool bear_break = close < lower

if bull_break and strategy.position_size <= 0
    if strategy.position_size < 0
        strategy.close("S", comment="flip flat")
    strategy.entry("L", strategy.long, comment="upper-band break")

if bear_break and strategy.position_size >= 0
    if strategy.position_size > 0
        strategy.close("L", comment="flip flat")
    strategy.entry("S", strategy.short, comment="lower-band break")

Overview

PF probe 105 - volty expansion close plots upper and lower bands based on the baseline SMA and a multiplier applied to standard deviation. Entries trigger when close breaks above the upper band for longs or below the lower band for shorts. The script flips existing positions before entering the opposite direction on a signal. It uses fixed position sizing of one unit with no stop loss. Main settings adjust band length from 2 to 200 and expansion multiple from 0.5 to 10.0. It repaints on the live bar only in edge cases of bar update ordering but otherwise signals on confirmed breaks.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge contributors 2026, as written in the script's header

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Volatility & bands, Moving averages, Breakout

Markets

Crypto

Timeframes

M15-H1

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

Settings

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

SettingTypeDefaultVariable
Baseline / stdev lengthint20i_len
Expansion multiplefloat2.0i_mult
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

Bollinger Breakout

by hackingthemarkets
189 stars

This price-chart strategy plots a simple moving average and upper and lower bands built from the standard deviation of close, scaled by separate offset inputs. It enters a fixed quantity long when close crosses above the upper band and a fixed quantity short w

Strategy v4 Volatility & bandsBreakout
Updated 3 years ago · None stated GitHub repository of Bollinger Breakout
106 stars

This strategy runs on the price chart and enters long when a fast simple moving average crosses above a slow one, and short on the opposite cross, while closing the other side. Entries also need ATR above a filter, a pullback check, a minimum candle-body chang

Strategy v5 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 9:22 5 MIN 15 MIN BANKNIFTY

均线突破交易系统

by tangly1024
76 stars

This strategy trades long breakouts of a fast and a slow moving average on the price chart. It opens a long position when price crosses above either average, using a percentage of equity as size. It reduces the position by a set share when the high reaches the

Strategy v5 TrendMoving averages
Updated 4 months ago · None stated GitHub repository of 均线突破交易系统

Bollinger bands examples

by tradingstrategy-ai
53 stars

This strategy plots exponential-moving-average Bollinger bands on the price chart and calculates RSI. It opens a long position when close crosses above the upper band while RSI is at or above a threshold, the date filter allows trading, and no position is open

Strategy v5 Volatility & bandsOscillators & momentum
Updated 3 years ago · None stated GitHub repository of Bollinger bands examples

Keltner Channels Strategy

by TWODS-CAPITAL
37 stars

This strategy builds Keltner-style bands around an exponential or simple moving average of the chosen source. Band width uses average true range, raw true range, or a smoothed high-low range, scaled by a multiplier. When the source crosses above the upper band

Strategy v5 Volatility & bandsBreakout
Updated 3 years ago · MIT GitHub repository of Keltner Channels Strategy
16 stars

This strategy plots Donchian channels, trailing stops, and profit targets directly on the price chart. It enters breakout trades using a 55-bar Donchian channel and sizes positions according to an ATR-based risk percentage per unit. The system adds units as pr

Strategy v6 TrendBreakout
Updated 11 months ago · None stated GitHub repository of Seykota Alt 10: Profit Targets

More strategys

Trade Your Charts With a Regulated Broker

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

Compare brokers