Strategy · Pine Script v6 · On the chart

PF probe market-shift-probe-integration

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

This strategy composes confirmed pivot breaks, a rolling price extreme, and a state-edge detector into overlay entries on the price chart.

View on GitHub

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

97 lines of Pine Script v6 from validation/composite-marketshift-integration-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-integration — pivot state + rolling extreme + edge entries
// Clean-room: written from validation goal, not from source.
//
// Purpose: composes the three surfaces isolated by `market-shift-probe-01..03`
// into a single end-to-end strategy. The engine surface under test is the
// cross-surface composition: pivot-driven `market_state` flips on price
// breaking the most-recent confirmed pivot (probe 01); the rolling-window
// extreme (probe 02) provides an alternative rebound entry; the edge
// detector (probe 03) ensures entries fire once per state transition.
//
// Entries use OR-of-AND composition rather than strict AND-of-all: a
// long fires either on a fresh bull state edge OR on a rolling-low
// rebound while in a bull state. Strict AND-composition requires pivot
// break and rolling-extreme cross to land on the same bar, which is
// vanishingly rare on 15m crypto and produces no trades at all. The
// OR-of-AND form still routes EVERY entry through all three surfaces:
// the state machine must be in the right regime, the rolling extreme
// must agree (or the pivot edge must fire), and the edge detector
// stops same-bar duplicates.
//
// Validation goal: bit-exact trade list against TradingView's broker emulator
// on the reference 15-minute ETH-USDT-USDT feed.
//
// 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-integration", shorttitle="PF_MSINT",
     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_pivot  = input.int(5,  "Pivot strength",        minval=2,  maxval=20)
int i_window = input.int(50, "Rolling window length", minval=10, maxval=200)

// ---- pivot tracking ------------------------------------------------
float ph = ta.pivothigh(high, i_pivot, i_pivot)
float pl = ta.pivotlow(low,   i_pivot, i_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

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

float ref_hi = roll_hi[1]
float ref_lo = roll_lo[1]

bool extreme_up   = ta.crossover(close,  ref_lo)
bool extreme_down = ta.crossunder(close, ref_hi)

// ---- state machine (probe 01 surface) ------------------------------
var int market_state = 0
var int prev_state   = 0

bool pivot_break_up   = not na(last_ph) and close > last_ph
bool pivot_break_down = not na(last_pl) and close < last_pl

if pivot_break_up
    market_state := 1
else if pivot_break_down
    market_state := -1

// ---- edge detector (probe 03 surface) ------------------------------
bool state_long_edge  = market_state ==  1 and prev_state !=  1
bool state_short_edge = market_state == -1 and prev_state != -1

// ---- composed entry (OR of two AND-gated surfaces) -----------------
// Fire long either:
//   (a) on a fresh bull state transition (probe 01 → 03 path), OR
//   (b) on a rolling-low rebound while in a bull state
//       (probe 02 ∧ 01 path).
// Same for short, mirrored. Every entry still passes through the
// state machine + at least one of {edge detector, rolling extreme}.
bool go_long  = (state_long_edge)  or (market_state ==  1 and extreme_up)
bool go_short = (state_short_edge) or (market_state == -1 and extreme_down)

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

if go_short and strategy.position_size >= 0
    strategy.entry("S", strategy.short, qty=1, comment="integ bear")

prev_state := market_state

Overview

Market state turns bullish when close breaks the latest confirmed pivot high and bearish on a break of the latest pivot low. A long fires on a fresh bullish state change or when close crosses above the prior rolling low while that state remains. Pivot strength and window length change confirmation delay and the extreme range. It uses a fixed quantity and has no stop loss by default, written for a 15-minute crypto feed.

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

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

(IK) Base Break Buy

by hasnocool
106 stars

This price-chart strategy marks a base when enough recent bar bottoms cluster within a set deviation of the current bottom, then ignores new bases that sit too close to existing ones. A buy is considered when price falls a chosen percentage below a base inside

Strategy v4 Support & resistanceBreakout
Updated 2 years ago · GPL-3.0 GitHub repository of (IK) Base Break Buy

Pivot Points - S/R Trading

by Basant1Saini
1 stars

Calculates classic support and resistance pivot levels using Traditional, Fibonacci, or Camarilla formulas from a higher timeframe. The strategy offers two execution modes: Bounce mode trades reversals within a customizable percentage buffer of support and res

Strategy v5 Support & resistanceBreakout
Updated 7 months ago · None stated GitHub repository of Pivot Points - S/R Trading
1 stars

This strategy identifies pivot-based Darvas Box levels on the price chart and trades re-entries following box sweeps. A long position arms when the price dips below the lower boundary and triggers when it closes back inside, provided the price is above a highe

Strategy v6 Support & resistanceBreakout
Updated 2 months ago · None stated GitHub repository of TN Sovereign Darvas Box v6

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

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