Strategy · Pine Script v6 · On the chart

Pivot Extension Break

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

A strategy that detects confirmed swing highs and lows using left and right bar counts, remembers the latest of each, and trades breaks of them.

View on GitHub

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

62 lines of Pine Script v6 from validation/ta-pivot-confirmed-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 102 — confirmed-pivot break extension
// Clean-room: written from validation goal, not from source.
//
// Purpose: exercises `ta.pivothigh(left, right)` / `ta.pivotlow(left, right)`
// at left==right==4, then carries the most-recent CONFIRMED pivot price
// across bars in `var float` storage and fires entries when the close
// extends past it. Two engine surfaces are pinned:
//   (1) Pivot confirmation latency: TV reports `ta.pivothigh` `right`
//       bars AFTER the actual swing; engines that resolve confirmation
//       earlier or later will desync the carry-state.
//   (2) `var` initialiser-once semantics: `last_ph` / `last_pl` must
//       hold their value across bars and update only on confirmation.
//
// Validation goal: bit-exact trade list against TradingView's broker
// emulator on the reference 15m feed. Pass = every breakout 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 102 - pivot extension break", shorttitle="PF_p102_PIV",
     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_left  = input.int(4, "Pivot left bars",  minval=1, maxval=20)
int i_right = input.int(4, "Pivot right bars", minval=1, maxval=20)

// ---- pivot detection ----------------------------------------------
float ph = ta.pivothigh(high, i_left, i_right)
float pl = ta.pivotlow(low,   i_left, i_right)

// ---- carry the most-recent confirmed pivot -----------------------
var float last_ph = na
var float last_pl = na

if not na(ph)
    last_ph := ph
if not na(pl)
    last_pl := pl

// ---- entries on close extending past the carried pivot -----------
bool long_break  = not na(last_ph) and close > last_ph
bool short_break = not na(last_pl) and close < last_pl

if long_break and strategy.position_size <= 0
    if strategy.position_size < 0
        strategy.close("S", comment="flip flat")
    strategy.entry("L", strategy.long, comment="pivot-high break")

if short_break and strategy.position_size >= 0
    if strategy.position_size > 0
        strategy.close("L", comment="flip flat")
    strategy.entry("S", strategy.short, comment="pivot-low break")

Overview

Pivot Extension Break goes long when the close exceeds the last confirmed pivot high and short when the close falls below the last confirmed pivot low, closing the opposite position first. Pivots are confirmed only after the right-side bars complete, so signals lag the swing. There is no stop loss. It runs on the price chart.

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, Support & resistance

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
Pivot left barsint4i_left
Pivot right barsint4i_right
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 yesterday · 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

STRG-HOLP

by harryguiacorn
219 stars

STRG-HOLP is a trading strategy that identifies High of Low Period (HOLP) and Low of High Period (LOHP) breakout setups. It tracks the lowest low or highest high over a user-defined lookback window. A long trade opens when the close breaks above the high of th

Strategy v5 BreakoutSupport & resistance
Updated 1 year ago · None stated GitHub repository of STRG-HOLP
106 stars

This script monitors opening gap conditions and breakout behavior relative to the first candle's range across up to twenty configurable stock tickers. It detects whether following bars remain inside the opening range before breaking out, displaying the status

Strategy v4 Screeners & dashboardsBreakout Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of 1St Bar GAP+BkOut Screener v2 by RM

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

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