Strategy · Pine Script v6 · On the chart

PF Probe 97c Range Expansion Pending Stop

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

A test strategy from a reference corpus that arms pending stop entries after a range expansion.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code55
Settings2inputs
LicenceApache-2.0
Last update6 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

55 lines of Pine Script v6 from validation/order-range-expansion-pending-stop-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 97c — range-expansion gated pending stop entry (isolated from probe 97)
// Clean-room: written from validation goal, not from source.
//
// Purpose: isolate the range-expansion predicate + pending stop entry
// lifecycle from probe 97. Drops bracket, drops cap. Uses
// `strategy.entry(..., stop=high[1])` for long arm and
// `strategy.entry(..., stop=low[1])` for short arm, gated by an
// ATR-relative range expansion test on the previous bar. Cancels the
// pending stop when the gate negates. If TV vs engine diverge here,
// either the range-expansion arithmetic (atr[1] history access) or
// the pending-stop placement / next-bar cancel lifecycle is the bug.
//
// Validation goal: bit-exact trade list. Pass = same set of bars trigger
// pending stop entries, same set get cancelled before fill, same fills.
//
// 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. Export "List of trades" → tv_trades.csv.
//@version=6
strategy("PF probe 97c - range-expansion pending-stop isolate", shorttitle="PF_p97c_RNG",
     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, calc_on_order_fills=false)

// ---- inputs --------------------------------------------------------
int   i_atr_len  = input.int(14, "ATR length",            minval=1)
float i_atr_mult = input.float(1.0, "Range/ATR threshold", minval=0.1)

// ---- range-expansion detection (mirrors probe 97 logic) ------------
float prev_range = high[1] - low[1]
float atr_now    = ta.atr(i_atr_len)
float atr_prev   = atr_now[1]
bool  expansion  = not na(atr_prev) and prev_range > atr_prev * i_atr_mult

bool prev_up   = close[1] > open[1]
bool prev_down = close[1] < open[1]

bool arm_long  = expansion and prev_up
bool arm_short = expansion and prev_down

// ---- pending stop entries; cancelled when arm negates --------------
if arm_long
    strategy.entry("LongOnRng", strategy.long, stop=high[1])
else
    strategy.cancel("LongOnRng")

if arm_short
    strategy.entry("ShortOnRng", strategy.short, stop=low[1])
else
    strategy.cancel("ShortOnRng")

Overview

When the previous bar's range exceeds a multiple of the prior ATR, it places a buy stop at the previous high if that bar closed up, or a sell stop at the previous low if it closed down. Pending orders are cancelled when the condition no longer holds. Inputs set the ATR length and range threshold. There is no stop loss, and commission and slippage are zero.

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

Breakout, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

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
ATR lengthint14i_atr_len
Range/ATR thresholdfloat1.0i_atr_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

257 stars

This strategy plots VWMA-based Bollinger bands on the 1-minute ES futures price chart for volatility analysis and potential breakout identification. It calculates dynamic long and short stop loss and take profit levels using percentage inputs relative to entry

Strategy v6 Volatility & bandsSupport & resistance
Updated 6 weeks ago · None stated GitHub repository of V1.6 ES - Futures 1M No Repaint
218 stars

This strategy detects price breakouts above rolling highest highs or below lowest lows over a customizable lookback period. It includes optional volume spike and ATR volatility threshold filters, along with bar confirmation rules. Positions are taken upon conf

Strategy v6 BreakoutVolatility & bands
Updated 3 months ago · None stated GitHub repository of Breakout Strategy Template

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

2 Candles Inside ATR

by hasnocool
106 stars

2 Candles Inside ATR is an overlay script that measures volatility compression across two consecutive candles. It calculates a smoothed Average True Range (ATR) and compares it against the combined high and low range of the current and previous bars. When the

Strategy v4 Volatility & bandsBreakout
Updated 2 years ago · GPL-3.0 GitHub repository of 2 Candles Inside ATR

均线突破交易系统

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 5 months ago · None stated GitHub repository of 均线突破交易系统

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