Strategy · Pine Script v6 · On the chart

MTF probe 10 - HTF bracket static

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

This long-only strategy identifies trend-following entries using moving average crossovers filtered by higher-timeframe trend alignment.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code75
Settings7inputs
LicenceApache-2.0
Last update7 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/mtf-htf-confluence-static-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
//
// MTF probe 10 — HTF confluence gate with STATIC bracket exit
//
// Purpose: isolate the MTF-state half of the VCP integration probe family's
// failure mode. That family gates entries on 1H htf trend confluence
// (request.security) and also re-issues a trailing stop every bar via
// repeated strategy.exit
// calls. This probe keeps ONLY the HTF confluence half — the bracket
// exit is set ONCE at entry and never touched again — so any TV/engine
// drift here is attributable to MTF state evaluation timing alone.
// The companion probe (mtf-probe-11-htf-bracket-manual-trail) keeps the
// same HTF gate but adds the per-bar manual trailing stop. Compare the
// two: if probe 10 matches and probe 11 doesn't, the gap is in the
// manual-trail pattern; if both fail, the gap is in HTF confluence.
//
// Trade shape: long-only, pyramiding=1. Enter when 15m EMA(9) crosses
// above EMA(21) AND the 1H htf close is above its 1H EMA(20). Exit
// via a static stop + ATR-multiple take-profit set at entry — NEVER
// re-issued. Bracket prices are captured into ``var float`` slots
// at entry time, so the engine's strategy.exit pending-order pruning
// can't be confused by per-bar recomputation.
//
// TV setup: 15m chart, ETH-USDT-USDT, same window as
// data/ohlcv_ETH-USDT-USDT_15m.csv. Export the trade list to trades.csv
// in this folder.
//@version=6
strategy("MTF probe 10 - HTF bracket static", shorttitle="MTF_p10",
     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 ---------------------------------------------------------
string i_htf       = input.timeframe("60",  "Higher Timeframe")
int    i_htf_ema   = input.int(20,          "HTF EMA Length",   minval=2, maxval=200)
int    i_fast_ema  = input.int(9,           "Fast EMA Length",  minval=2, maxval=50)
int    i_slow_ema  = input.int(21,          "Slow EMA Length",  minval=3, maxval=100)
int    i_atr_len   = input.int(14,          "ATR Length",       minval=2, maxval=50)
float  i_stop_mult = input.float(2.0,       "Stop ATR mult",    minval=0.5, maxval=5.0, step=0.1)
float  i_tp_mult   = input.float(4.0,       "Take-profit ATR mult", minval=0.5, maxval=10.0, step=0.1)

// ---- 15m series -----------------------------------------------------
float emaFast = ta.ema(close, i_fast_ema)
float emaSlow = ta.ema(close, i_slow_ema)
float atrVal  = ta.atr(i_atr_len)

// ---- HTF confluence (1H by default) --------------------------------
// Pre-compute the htf EMA at global scope so request.security pulls a
// stable expression (same pattern VCP uses for its mtf checks). Engine
// must materialize this with lookahead_off semantics so we never see a
// future htf-bar value.
float _htfEmaSeries = ta.ema(close, i_htf_ema)
float htfClose = request.security(syminfo.tickerid, i_htf,
     close, barmerge.gaps_off, barmerge.lookahead_off)
float htfEma   = request.security(syminfo.tickerid, i_htf,
     _htfEmaSeries, barmerge.gaps_off, barmerge.lookahead_off)
bool  htfBull  = not na(htfClose) and not na(htfEma) and htfClose > htfEma

// ---- entry ---------------------------------------------------------
bool longSig = ta.crossover(emaFast, emaSlow) and htfBull

// Static bracket levels captured at entry. Initialized to na so they
// can't fire pre-entry; once set, never recomputed.
var float entryStop = na
var float entryTP   = na

if longSig and strategy.position_size == 0 and not na(atrVal)
    entryStop := close - atrVal * i_stop_mult
    entryTP   := close + atrVal * i_tp_mult
    strategy.entry("L", strategy.long, qty=1, comment="entry long")
    strategy.exit("LX", "L", stop=entryStop, limit=entryTP,
         comment="static bracket")

Overview

MTF probe 10 - HTF bracket static plots directly on the main price chart. Entries trigger when a fast exponential moving average crosses above a slow moving average, provided the price on a higher timeframe closes above its respective exponential moving average. Upon entry, the strategy submits a static bracket order with an Average True Range stop loss and profit target using fixed single-unit position sizing. Key settings configure moving average lengths, higher-timeframe periods, and bracket multipliers. Trades do not adjust trailing stops once active.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge contributors 2026, as written in the script's header

Draws

On the price chart

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
Higher Timeframetimeframe60i_htf
HTF EMA Lengthint20i_htf_ema
Fast EMA Lengthint9i_fast_ema
Slow EMA Lengthint21i_slow_ema
ATR Lengthint14i_atr_len
Stop ATR multfloat2.0i_stop_mult
Take-profit ATR multfloat4.0i_tp_mult
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

Doge SMA

by hackingthemarkets
474 stars

Doge SMA is a long-only moving-average crossover strategy drawn on the price chart. It calculates a fast and a slow simple moving average of close and enters a long position when the fast average crosses above the slow average, but only inside a user-defined s

Strategy v4 TrendMoving averages
Updated 4 years ago · None stated GitHub repository of Doge SMA

This strategy calculates and plots a fast Exponential Moving Average (EMA) and a slow EMA directly on the main price chart. It enters long trades when the fast EMA crosses above the slow EMA and exits when the fast EMA crosses below the slow EMA. Inputs allow

Strategy v6 TrendMoving averages
Updated 2 days ago · AGPL-3.0 GitHub repository of Forven S01508 — Simple EMA20/50 Cross
330 stars

2 EMA/SMA + RSI Strategy [Alorse] combines three configurable moving averages with a short-period Relative Strength Index filter. It plots fast, slow, and trend moving averages on the price chart. Long entries trigger when the fast moving average is above the

Strategy v4 TrendOscillators & momentum
Updated 2 months ago · None stated GitHub repository of 2 EMA/SMA + RSI Strategy [Alorse]

Acrypto - Weighted Strategy

by AlbertoCuadra
318 stars

This strategy plots on the price chart and opens long or short positions when a weighted score from MACD, Stochastic RSI, RSI, Supertrend and a moving-average crossover exceeds a user-set trigger. Each component has its own weight and candle delay. Entries can

Strategy v5 TrendOscillators & momentum
Updated 3 years ago · Custom licence GitHub repository of Acrypto - Weighted Strategy
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 7 weeks ago · None stated GitHub repository of 30s - ES 1m Strategy Candle Bar

EMA Crossover Strategy

by TradersPost
228 stars

EMA Crossover Strategy plots a fast and a slow exponential moving average on the price chart. It treats a confirmed fast-over-slow cross as a long condition and a confirmed cross under as a short condition. Position size is a percentage of equity. Optional per

Strategy v6 TrendMoving averages
Updated 3 months ago · None stated GitHub repository of EMA Crossover Strategy

More Trend scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers