Strategy · Pine Script v6 · On the chart

PF MTF Probe 08 Triple TF MACD Histogram

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

A test strategy from a reference corpus that calls a user-defined MACD histogram function on 60-minute, 4-hour and daily data with lookahead off.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code47
Settings0inputs
LicenceApache-2.0
Last update6 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

47 lines of Pine Script v6 from validation/mtf-triple-tf-macd-hist-confluence-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 08 — triple HTF MACD histogram via user-defined function
//
// Purpose: replicate the IES integration probe family's bias pattern in the
// smallest possible strategy. That family wraps MACD histogram in
// `f_macd_hist(src, fast, slow, sig)` and calls it inside three
// request.security feeds (60m, 240m, D), then counts how many HTF buckets
// are bullish/bearish for entry. This combines "user-defined function
// inside request.security" + "three concurrent HTFs" + "ta.ema chain".
// MTF probes 03/05 cover ta.* inside security at a single HTF; probe 07
// covers three HTFs with a flat expression. probe 08 covers the full
// triple-HTF user-function shape so the engine vs TV gap can be attributed
// to one of these specific axes.
//
// TV setup: 15m chart, same symbol/window as data/ohlcv_ETH-USDT-USDT_15m.csv.
// Export TradingView "List of trades" to trades.csv in this folder.
//@version=6
strategy("PF MTF probe 08 - triple TF MACD hist", shorttitle="MTF_p08_3MACD", 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)

f_macd_hist(series float src, int fast, int slow, int sig) =>
    float macd_val = ta.ema(src, fast) - ta.ema(src, slow)
    float macd_sig = ta.ema(macd_val, sig)
    macd_val - macd_sig

float h1 = request.security(syminfo.tickerid, "60",  f_macd_hist(close, 12, 26, 9), lookahead=barmerge.lookahead_off)
float h2 = request.security(syminfo.tickerid, "240", f_macd_hist(close, 12, 26, 9), lookahead=barmerge.lookahead_off)
float h3 = request.security(syminfo.tickerid, "D",   f_macd_hist(close, 12, 26, 9), lookahead=barmerge.lookahead_off)

bool allBull = h1 > 0 and h2 > 0 and h3 > 0
bool allBear = h1 < 0 and h2 < 0 and h3 < 0

if allBull and strategy.position_size <= 0
    if strategy.position_size < 0
        strategy.close("S", comment="flip to long")
    strategy.entry("L", strategy.long, comment="3-TF MACD bull")

if allBear and strategy.position_size >= 0
    if strategy.position_size > 0
        strategy.close("L", comment="flip to short")
    strategy.entry("S", strategy.short, comment="3-TF MACD bear")

Overview

PF MTF Probe 08 Triple TF MACD Histogram goes long when all three histograms are positive and short when all three are negative, closing the opposite position first. One unit is traded with no stop loss, commission or slippage. It draws no indicators. The script is meant to compare engine output with a reference platform, not for live trading.

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

Any symbol

Timeframes

M15-H1

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

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

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

Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish

Strategy v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Strategy
228 stars

This strategy generates trading signals based on a selectable momentum engine, supporting MACD, RSI, Stochastic, or Rate of Change. Entries trigger on signal crosses, zero-line crosses, or threshold crosses, with an optional moving average trend filter. Risk m

Strategy v6 Oscillators & momentumTrend
Updated 3 months ago · None stated GitHub repository of Momentum Strategy Template

255 EMA Strategy

by hasnocool
106 stars

255 EMA Strategy combines an exponential moving average with Average True Range bands and standard MACD crossovers to generate entry signals. Drawn directly on the price chart, it plots the central 255 EMA along with upper and lower volatility envelopes. Trade

Strategy v4 Moving averagesOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 255 EMA Strategy

More Oscillators & momentum 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