Strategy · Pine Script v6 · On the chart

PF probe trendmaster-probe-03-pivot-tp-sl

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

This strategy detects long and short signals using a fast EMA crossing above or below a slow EMA.

View on GitHub

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

75 lines of Pine Script v6 from validation/composite-trendmaster-pivot-anchored-bracket-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 trendmaster-probe-03-pivot-tp-sl — TP/SL anchored to recent pivots, not fixed offset
// Clean-room: written from validation goal, not from source.
//
// Purpose: isolates the pivot-anchored bracket surface used by trend
// strategies that risk-frame each entry against the last confirmed swing.
// SL for a long is set to the most recent pivot LOW; TP is computed as a
// 2R extrapolation from entry (`entry + (entry - last_pl) * 2`). Short is
// symmetric off the most recent pivot HIGH. The engine surface under test
// is (a) cross-bar `var float` pivot retention, (b) on-entry derivation
// of bracket prices using `strategy.position_avg_price`, (c) the
// `strategy.exit` placement of asymmetric stop/limit pairs.
//
// Validation goal: bit-exact trade list against TradingView's broker emulator
// on the reference 15-minute ETH-USDT-USDT feed. SL and TP fill prices must
// match TV exactly; any drift in pivot retention will shift both sides of
// the bracket.
//
// 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 trendmaster-probe-03-pivot-tp-sl", shorttitle="PF_TM03_PVTP",
     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)
float i_rr      = input.float(2.0, "Reward:risk ratio", minval=0.5, maxval=10.0, step=0.5)
int   i_fast    = input.int(5,    "Fast EMA", minval=2, maxval=50)
int   i_slow    = input.int(13,   "Slow EMA", minval=3, maxval=100)

// ---- pivot retention ----------------------------------------------
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

// ---- entry trigger: simple EMA cross -----------------------------
float ema_fast = ta.ema(close, i_fast)
float ema_slow = ta.ema(close, i_slow)

bool long_signal  = ta.crossover(ema_fast,  ema_slow)
bool short_signal = ta.crossunder(ema_fast, ema_slow)

// ---- entries (only when a pivot anchor exists) -------------------
if long_signal and not na(last_pl) and strategy.position_size <= 0
    strategy.entry("L", strategy.long, qty=1, comment="pivot long")

if short_signal and not na(last_ph) and strategy.position_size >= 0
    strategy.entry("S", strategy.short, qty=1, comment="pivot short")

// ---- pivot-anchored bracket --------------------------------------
float entry_px = strategy.position_avg_price

if strategy.position_size > 0 and not na(last_pl)
    float sl_px = last_pl
    float tp_px = entry_px + (entry_px - last_pl) * i_rr
    strategy.exit("Brk", from_entry="L", stop=sl_px, limit=tp_px)

if strategy.position_size < 0 and not na(last_ph)
    float sl_px = last_ph
    float tp_px = entry_px - (last_ph - entry_px) * i_rr
    strategy.exit("Brk", from_entry="S", stop=sl_px, limit=tp_px)

Overview

Entries only trigger when a recent pivot exists for anchoring. Long entries place a stop loss at the last pivot low and a take profit at 2R distance using the entry price. Short entries use the last pivot high for stop loss and symmetric 2R take profit. The script retains the most recent valid pivot prices across bars. All calculations and exits occur on the price chart with default 1-unit fixed position sizing.

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

Markets

Crypto

Timeframes

M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

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
Reward:risk ratiofloat2.0i_rr
Fast EMAint5i_fast
Slow EMAint13i_slow
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

Omar Edited WF

by Alorse
330 stars

Omar Edited WF is a trading strategy overlay built around Williams Fractals and multiple Exponential Moving Averages. It detects high and low fractal pivot points over configurable lookback periods alongside three adjustable EMA trendlines. Long entries are ma

Strategy v5 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of Omar Edited WF
257 stars

This strategy calculates dynamic support and resistance levels using pivot highs and lows alongside a custom smoothed trend filter and a 3-period EMA. It identifies entry opportunities when price breaks out relative to the trend filter and short-term EMA cross

Strategy v5 TrendSupport & resistance Repaints
Updated 6 weeks ago · None stated GitHub repository of 30s - ES 1m Strategy Candle Bar

This strategy overlays the price chart and looks for VWAP pullbacks. It goes long when a short SMA crosses above VWAP after RSI has been oversold within ten bars, and short on the opposite cross after RSI has been overbought. Optional Minervini-style moving-av

Strategy v5 TrendOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of Advanced VWAP-Momentum Pullback Trend Qualifier
104 stars

This strategy combines three Exponential Moving Averages with Williams Fractals to execute trend-following or mean-reverting trades. It analyzes price structure using short, medium, and long-term EMAs along with fractal highs and lows. Entries trigger when fra

Strategy v5 TrendMoving averages
Updated 3 years ago · MIT GitHub repository of 3MA and Fractals Strategy

This strategy executes trades based on pivot levels, an exponential moving average, and a multi-stage smoothing trend line. It identifies support and resistance points from pivot highs and lows, combining them with price relationship rules against a custom smo

Strategy v5 TrendMoving averages Repaints
Updated 2 years ago · None stated GitHub repository of Binancash - Candle Strategy Futures on Binance
13 stars

This strategy generates entry signals using pivot points and uses custom Curie moving average closing lines for exiting positions. It features risk management components including percentage-based stop loss, take profit, trailing stops, and break-even levels,

Strategy v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of BitLa PivotPoints A002

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