Strategy · Pine Script v6 · On the chart

PF probe market-shift-probe-02-rolling-extreme

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

This Pine Script strategy computes rolling highest and lowest prices over a user-set window.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code51
Settings1inputs
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

51 lines of Pine Script v6 from validation/composite-marketshift-rolling-highest-lowest-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 market-shift-probe-02-rolling-extreme — rolling highest/lowest tracking
// Clean-room: written from validation goal, not from source.
//
// Purpose: isolates the rolling-window extreme surface (`ta.highest(high, N)`
// and `ta.lowest(low, N)`) used by shift detectors to anchor their
// rebound/breakout reference levels. Entry triggers on `ta.crossover(close,
// ta.lowest(low, N)[1])` (close pierces the prior bar's rolling low →
// rebound long); short is symmetric on `ta.crossunder(close,
// ta.highest(high, N)[1])`. Using the [1]-shifted reference avoids the
// trivial "close == lowest" same-bar tautology and exercises history-access
// alignment in TV vs the engine.
//
// Validation goal: bit-exact trade list against TradingView's broker emulator
// on the reference 15-minute ETH-USDT-USDT feed. The window-length surface
// is the only meaningful drift candidate — `ta.highest`/`ta.lowest` warmup
// and series-history precision should agree perfectly through bar 50+.
//
// 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 market-shift-probe-02-rolling-extreme", shorttitle="PF_MS02_ROLL",
     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_window = input.int(50, "Rolling window length", minval=10, maxval=200)

// ---- rolling extremes ---------------------------------------------
float roll_hi = ta.highest(high, i_window)
float roll_lo = ta.lowest(low,   i_window)

// Reference the prior-bar value so the cross is not a self-tautology.
float ref_hi = roll_hi[1]
float ref_lo = roll_lo[1]

bool long_signal  = ta.crossover(close,  ref_lo)
bool short_signal = ta.crossunder(close, ref_hi)

// ---- routing -------------------------------------------------------
if long_signal and strategy.position_size <= 0
    strategy.entry("L", strategy.long, qty=1, comment="rebound long")

if short_signal and strategy.position_size >= 0
    strategy.entry("S", strategy.short, qty=1, comment="rebound short")

Overview

PF probe market-shift-probe-02-rolling-extreme draws reference levels on the price chart and issues long signals on close crossing the prior rolling low plus short signals on close crossing the prior rolling high. The strategy enters long positions on buy signals when flat and short positions on sell signals when flat. The sole input changes the rolling window length between 10 and 200 bars. It uses fixed size of one unit per trade and overlays all elements directly on the price chart. No stop-loss or take-profit rules exist, with exits occurring only on the opposite signal.

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

Trend, Support & resistance, 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
Rolling window lengthint50i_window
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

This trend-following strategy executes a classic Donchian channel breakout system designed to cross-validate backtest results against external framework benchmarks. It triggers a long entry when the closing price breaks above the highest high of the prior entr

Strategy v6 BreakoutTrend
Updated today · AGPL-3.0 GitHub repository of Forven S01509 - Simple Donchian 20/10 Breakout
257 stars

This strategy plots running pivot highs as red R circles and pivot lows as blue S circles directly on the price chart. It computes an EMA 3 and a Cto trend line from close prices, then generates long signals on upward EMA-Cto crossovers combined with price pos

Strategy v6 TrendMoving averages Repaints
Updated 6 weeks ago · None stated GitHub repository of Best Chart 1m Strategy Candle Bar
106 stars

Calculates multi-period logarithmic regression trend channels and deviation bands across up to twenty selectable lookback lengths directly on the price chart. It evaluates channel slopes and Pearson's correlation coefficient to detect market trends and generat

Strategy v5 TrendSupport & resistance Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of Advanced Trend Detection Strategy

This trend breakout strategy plots Donchian Channels consisting of upper, lower, and middle bands directly on the main price chart. Long positions enter when price touches the upper channel and pulls back to or below the middle band, placing a stop loss at the

Strategy v6 TrendBreakout
Updated 2 months ago · MPL-2.0 GitHub repository of Donchian Strategy - Dynamic TP, Fixed SL, 1% Risk, Daily Target
43 stars

This strategy executes trades on short-term cryptocurrency charts using a combination of pivot support and resistance levels and a multi-pole smoothed trend filter. Entries trigger when price crosses the smoothed trend line and confirms above or below a short-

Strategy v5 TrendBreakout Repaints
Updated 2 years ago · None stated GitHub repository of SOL 1m - Strategy Candle Bar

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