Strategy · Pine Script v6 · On the chart

PF Probe Trendmaster Trend Line Projection

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

PF Probe Trendmaster Trend Line Projection is a Pine Script strategy designed to evaluate trend line projections and slope math.

View on GitHub

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

92 lines of Pine Script v6 from validation/composite-trendmaster-line-new-projection-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-01-trend-line-projection — line.new() chain stress with projection entry
// Clean-room: written from validation goal, not from source.
//
// Purpose: isolates the `line.new()` drawing-object chain surface used by
// trend-line strategies that draw a fresh line on every confirmed pivot
// pair. Each new pivot connects the previous-pivot bar to the current
// pivot bar with `line.new(x1, y1, x2, y2)`, where x coordinates are
// `bar_index` offsets. `max_lines_count=500` caps the visible chain;
// older lines are auto-dropped by TV. The engine surface under test is
// (a) parsing `line.new` and the `max_lines_count` script header field,
// (b) bar_index arithmetic for line endpoints, (c) computing a slope
// projection from the most recent line and using it as an entry trigger.
// Drawing primitives have no PnL effect on TV — the entry is driven off
// the SLOPE arithmetic, which the engine must evaluate identically.
//
// Validation goal: bit-exact trade list against TradingView's broker emulator
// on the reference 15-minute ETH-USDT-USDT feed. If the engine doesn't draw
// lines but evaluates the slope projection correctly, parity still holds —
// only the slope math feeds the entry.
//
// 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-01-trend-line-projection", shorttitle="PF_TM01_LINE",
     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, max_lines_count=500)

// ---- inputs --------------------------------------------------------
int i_pivot = input.int(5, "Pivot strength", minval=2, maxval=20)

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

// ---- track last + previous confirmed pivot for line drawing ------
// last_* = most recent confirmed pivot, prev_* = the one before that.
var float last_ph_y = na
var int   last_ph_x = na
var float prev_ph_y = na
var int   prev_ph_x = na
var float last_pl_y = na
var int   last_pl_x = na
var float prev_pl_y = na
var int   prev_pl_x = na

// On confirm, ph/pl carry the pivot value; the actual swing bar is
// `i_pivot` bars back. Roll last_* into prev_* before overwriting.
if not na(ph)
    int cur_x = bar_index - i_pivot
    if not na(last_ph_y) and not na(last_ph_x)
        line.new(last_ph_x, last_ph_y, cur_x, ph, color=color.red)
    prev_ph_y := last_ph_y
    prev_ph_x := last_ph_x
    last_ph_y := ph
    last_ph_x := cur_x

if not na(pl)
    int cur_x = bar_index - i_pivot
    if not na(last_pl_y) and not na(last_pl_x)
        line.new(last_pl_x, last_pl_y, cur_x, pl, color=color.green)
    prev_pl_y := last_pl_y
    prev_pl_x := last_pl_x
    last_pl_y := pl
    last_pl_x := cur_x

// ---- slope-extrapolated reference at current bar -----------------
float ref_lo = na
if not na(prev_pl_y) and not na(prev_pl_x) and not na(last_pl_y) and not na(last_pl_x) and last_pl_x != prev_pl_x
    float slope = (last_pl_y - prev_pl_y) / (last_pl_x - prev_pl_x)
    ref_lo := last_pl_y + slope * (bar_index - last_pl_x)

float ref_hi = na
if not na(prev_ph_y) and not na(prev_ph_x) and not na(last_ph_y) and not na(last_ph_x) and last_ph_x != prev_ph_x
    float slope = (last_ph_y - prev_ph_y) / (last_ph_x - prev_ph_x)
    ref_hi := last_ph_y + slope * (bar_index - last_ph_x)

// ---- entries on slope-projection cross ----------------------------
bool long_signal  = not na(ref_lo) and ta.crossover(close,  ref_lo)
bool short_signal = not na(ref_hi) and ta.crossunder(close, ref_hi)

if long_signal and strategy.position_size <= 0
    strategy.entry("L", strategy.long, qty=1, comment="proj long")

if short_signal and strategy.position_size >= 0
    strategy.entry("S", strategy.short, qty=1, comment="proj short")

Overview

PF Probe Trendmaster Trend Line Projection identifies swing pivot highs and lows using a configurable pivot strength setting and draws trend lines directly on the price chart connecting consecutive pivot points. Entry triggers are evaluated using slope projections derived from these pivot lines. Drawn on the price overlay, the script allows users to adjust pivot sensitivity. Note that pivot detection requires confirmation bars, introducing inherent lag, and the strategy contains no stop loss by default.

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

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
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 today · AGPL-3.0 GitHub repository of Forven S01509 - Simple Donchian 20/10 Breakout

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
106 stars

This overlay strategy plots a two-timeframe Ichimoku setup on the price chart, with Tenkan, Kijun, Chikou, and Kumo from a base higher timeframe and an optional highest-timeframe cloud. It allows two entries in the same direction and uses ATR-based trailing st

Strategy v4 TrendVolatility & bands
Updated 2 years ago · GPL-3.0 GitHub repository of 2Tier Ichimoku Pyramiding [Takazudo]
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

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