Strategy · Pine Script v6 · On the chart

PF Probe Liquidity-Sweep-Probe-02-Sweep-Bar

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

This strategy detects liquidity sweep patterns based on pivot high and pivot low levels calculated over configurable left and right bar periods.

View on GitHub

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

55 lines of Pine Script v6 from validation/composite-liqsweep-wick-pierce-close-back-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 liquidity-sweep-probe-02-sweep-bar — wick-pierce + close-back-inside
// Clean-room: written from validation goal, not from source.
//
// Purpose: isolates the sweep-bar pattern: a candle whose wick pierces the
// most recently confirmed swing high (or low) but whose close returns
// inside the prior range. The engine surfaces under test are pivot-state
// retention (`var float last_ph`/`last_pl`) and the per-bar boolean
// composition (`high > last_ph and close < last_ph` for a bearish sweep
// of highs; symmetric for bullish sweep of lows). The bullish sweep-of-
// lows triggers a long entry; the bearish sweep-of-highs triggers a
// short entry — the standard liquidity-grab interpretation.
//
// Validation goal: bit-exact entries on the bar that completes a sweep
// pattern. Pass = identical trade list vs TradingView's broker emulator.
//
// 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 liquidity-sweep-probe-02-sweep-bar", shorttitle="PF_lsp02_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 --------------------------------------------------------
int i_left  = input.int(5, "Pivot left bars",  minval=1)
int i_right = input.int(5, "Pivot right bars", minval=1)

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

var float last_ph = na
var float last_pl = na

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

// ---- sweep patterns ------------------------------------------------
bool sweep_high = not na(last_ph) and high > last_ph and close < last_ph
bool sweep_low  = not na(last_pl) and low  < last_pl and close > last_pl

// ---- order routing -------------------------------------------------
if sweep_low and strategy.position_size <= 0
    strategy.entry("L", strategy.long, qty=1, comment="bullish sweep long")

if sweep_high and strategy.position_size >= 0
    strategy.entry("S", strategy.short, qty=1, comment="bearish sweep short")

Overview

A bullish sweep occurs when a candle's low pierces below the most recent pivot low while closing back above it, triggering a long entry. Conversely, a bearish sweep occurs when a candle's high pierces above the last pivot high but closes back below it, triggering a short entry. Drawn directly on the price chart, the strategy reverses existing positions on new signals and contains no default stop loss or exit targets.

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, Mean reversion

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
Pivot left barsint5i_left
Pivot right barsint5i_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

FairValueGap E003

by ruckard
13 stars

Calculates the distance between the current price and the opposite end of the latest fair value gap, entering trades on the expectation that price will partially fill the gap. It incorporates risk management with customizable stop loss, take profit based on ri

Strategy v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · None stated GitHub repository of FairValueGap E003

Wyckoff Phase

by muammeryldrm42
7 stars

This strategy identifies Wyckoff consolidation ranges directly on the price chart to trade potential spring and upthrust events. It calculates highest highs and lowest lows over a customizable lookback period, filtering setups by average volume spikes and ATR

Strategy v5 SMC / ICT / price actionSupport & resistance
Updated 3 months ago · MIT GitHub repository of Wyckoff Phase
1 stars

This Pine Script strategy detects ICT smart money concepts including order test zones, fair value gaps, and wicks on BTC and XAUUSD price charts. It calculates swings using pivot high and low. Signals enter long or short when the order test zone is hit with su

Strategy v5 SMC / ICT / price actionCandlestick patterns
Updated 6 months ago · None stated GitHub repository of ICT v4-weinkya BTC Improved

SMC + VWAP Edge Strategy

by StockPro-AI
1 stars

This strategy combines Smart Money Concepts with Order Blocks and Fair Value Gaps alongside multiple VWAP levels including session, weekly, monthly, and anchored variants. It detects confluence zones to generate long and short entry signals on the price chart.

Strategy v6 SMC / ICT / price actionSupport & resistance
Updated 6 months ago · None stated GitHub repository of SMC + VWAP Edge Strategy
330 stars

This strategy divides a fixed price range between an upper and a lower limit into equally spaced grid levels and plots them on the price chart. It marks a buy when price crosses down through a grid and a sell when price crosses up through a grid, using either

Strategy v5 Support & resistanceMean reversion Repaints
Updated 2 months ago · None stated GitHub repository of Grid Bot Simulator [Alorse]

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