Strategy · Pine Script v6 · On the chart

PF IES probe 06 - pivot sweep

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

This Pine Script strategy detects pivot liquidity sweeps on the price chart.

View on GitHub

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

66 lines of Pine Script v6 from validation/composite-ies-pivot-liquidity-sweep-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
//
// IES probe 06 — pivot-tracked liquidity sweep detection
//
// Purpose: isolate the IES integration probe family's structure / sweep
// layer. That family detects pivots with `ta.pivothigh(high, 10, 5)` and
// `ta.pivotlow(low, 10, 5)` (left=10, right=5), tracks the most-recent
// confirmed pivot in `var float last_swing_high / last_swing_low`, then
// flags a "sweep" when price pierces that pivot intra-bar but closes back
// the other side:
//
//   sweep_high = high  > last_swing_high and close < last_swing_high
//   sweep_low  = low   < last_swing_low  and close > last_swing_low
//
// Two numerical edges live here. (1) `ta.pivothigh/low` confirms a pivot
// `right` bars *after* the candidate, so the pivot stamp is delayed —
// engine vs TV must agree on exactly which bar receives the non-na
// pivothigh value. (2) The `var float` hand-off is a cumulative state
// machine that depends on every prior pivot in the dataset; any single
// missed/extra pivot permanently shifts the sweep boundary going forward.
//
// Trade shape: enter long on `sweep_low` (a stop-hunt reversal up); flip
// to short on `sweep_high`. No exit logic beyond the flip — keeps the
// number of trades equal to the number of detected sweeps.
//
// TV setup: 15m chart, ETH-USDT-USDT, same window as
// data/ohlcv_ETH-USDT-USDT_15m.csv. Export "List of trades" → trades.csv.
//@version=6
strategy("PF IES probe 06 - pivot sweep", shorttitle="IES_p06_SWP", 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 (mirrored from IES) ------------------------------------
int i_swing_left  = input.int(10, "Swing Left Bars",  minval=3, maxval=30)
int i_swing_right = input.int(5,  "Swing Right Bars", minval=2, maxval=15)

// ---- pivots (left/right asymmetric to match IES) -------------------
float swing_high = ta.pivothigh(high, i_swing_left, i_swing_right)
float swing_low  = ta.pivotlow(low,   i_swing_left, i_swing_right)

// ---- var-state pivot memory (IES exact pattern) --------------------
var float last_swing_high = na
var float last_swing_low  = na

if not na(swing_high)
    last_swing_high := swing_high
if not na(swing_low)
    last_swing_low := swing_low

// ---- sweep detection: pierce intra-bar, close back through ---------
bool sweep_high = not na(last_swing_high) and high > last_swing_high and close < last_swing_high
bool sweep_low  = not na(last_swing_low)  and low  < last_swing_low  and close > last_swing_low

if sweep_low and strategy.position_size <= 0
    if strategy.position_size < 0
        strategy.close("S", comment="flip")
    strategy.entry("L", strategy.long, qty=1, comment="sweep low → long")

if sweep_high and strategy.position_size >= 0
    if strategy.position_size > 0
        strategy.close("L", comment="flip")
    strategy.entry("S", strategy.short, qty=1, comment="sweep high → short")

Overview

PF IES probe 06 - pivot sweep identifies swing highs and lows using ta.pivothigh and ta.pivotlow with user-defined left and right bar counts. The script maintains state for the last confirmed pivot and flags a sweep when price pierces the pivot but closes back to the other side. It enters long positions on sweep lows and short positions on sweep highs, flipping existing positions as needed. No additional exit rules are present beyond position flips, and there is no stop loss. The primary settings modify the swing bar parameters to tune the sensitivity of pivot detection.

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

SMC / ICT / price action, Support & resistance, Breakout, Trend

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
Swing Left Barsint10i_swing_left
Swing Right Barsint5i_swing_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

Qtus SMC-Sniper AutoTrader v2 is an automated trading strategy plotted on the price chart that combines Smart Money Concepts (SMC), ICT frameworks, price action patterns, and technical indicators into a multi-factor scoring engine. It enters long or short posi

Strategy v6 SMC / ICT / price actionTrend
Updated 2 months ago · Custom licence GitHub repository of Qtus SMC-Sniper AutoTrader v2

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

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