Strategy · Pine Script v6 · On the chart

PF IES probe 03 - rsi+macd momentum

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

This strategy scores bullish and bearish momentum from three conditions: RSI above or below adjustable levels, RSI compared with its value three bars earlier, and a MACD histogram that is positive or negative and moving further that way.

View on GitHub

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

88 lines of Pine Script v6 from validation/composite-ies-rsi-macd-momentum-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
//
// IES probe 03 — RSI(14) + rsi[3] direction + MACD(12,26,9) histogram
//
// Purpose: isolate the IES integration probe family's momentum layer.
// That family synthesises a 0-3 "momentum score" per side from three terms:
//
//   rsi_bullish      = rsi > 55                          (RSI threshold)
//   rsi_momentum_up  = rsi > rsi[3]                      (RSI 3-bar memory)
//   macd_bullish     = macd_hist > 0 and > macd_hist[1]  (MACD hist memory)
//
// Both `rsi[3]` and `macd_hist[1]` are series-history references whose value
// on the boundary bar can disagree between the engine and TV if the inner
// ta.* chain warms up differently or if the [N] indexer is computed before
// vs after the current-bar value is materialised. MACD histogram is a
// triple-EMA chain (ema(12) − ema(26) → ema(9) → diff) so any 1-tick early
// drift propagates into the [1] memory.
//
// Trade shape: long when `momentum_bull_score >= 2` rises through 2 (i.e.
// the boundary crossing into bullish-2-of-3); short when bear score crosses
// into 2. Entry on rising-edge through threshold, flip on opposite. This
// preserves IES's "2-of-3 rule" exactly while shedding the rest of the
// strategy.
//
// TV setup: 15m chart, ETH-USDT-USDT, same window as
// data/ohlcv_ETH-USDT-USDT_15m.csv. Export "List of trades" → trades.csv.
//@version=6
strategy("PF IES probe 03 - rsi+macd momentum", shorttitle="IES_p03_MOM", 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 (mirrored from IES) ------------------------------------
int   i_rsi_len   = input.int(14,   "RSI Period",       minval=5,  maxval=30)
float i_rsi_bull  = input.float(55, "RSI Bullish Level",minval=50, maxval=70)
float i_rsi_bear  = input.float(45, "RSI Bearish Level",minval=30, maxval=50)
int   i_macd_fast = input.int(12,   "MACD Fast",        minval=5,  maxval=20)
int   i_macd_slow = input.int(26,   "MACD Slow",        minval=15, maxval=50)
int   i_macd_sig  = input.int(9,    "MACD Signal",      minval=3,  maxval=15)

// ---- RSI + 3-bar direction memory ----------------------------------
float rsi = ta.rsi(close, i_rsi_len)
bool rsi_bullish     = rsi > i_rsi_bull
bool rsi_bearish     = rsi < i_rsi_bear
bool rsi_momentum_up = rsi > rsi[3]
bool rsi_momentum_dn = rsi < rsi[3]

// ---- MACD histogram (IES's exact pattern, inline rather than UDF) --
float macd_line   = ta.ema(close,     i_macd_fast) - ta.ema(close, i_macd_slow)
float macd_signal = ta.ema(macd_line, i_macd_sig)
float macd_hist   = macd_line - macd_signal

bool macd_bullish = macd_hist > 0 and macd_hist > macd_hist[1]
bool macd_bearish = macd_hist < 0 and macd_hist < macd_hist[1]

// ---- 2-of-3 momentum scores ---------------------------------------
int momentum_bull_score = 0
if rsi_bullish
    momentum_bull_score += 1
if rsi_momentum_up
    momentum_bull_score += 1
if macd_bullish
    momentum_bull_score += 1

int momentum_bear_score = 0
if rsi_bearish
    momentum_bear_score += 1
if rsi_momentum_dn
    momentum_bear_score += 1
if macd_bearish
    momentum_bear_score += 1

// ---- enter on rising-edge through 2-of-3 ---------------------------
bool long_entry  = momentum_bull_score >= 2 and momentum_bull_score[1] < 2 and strategy.position_size <= 0
bool short_entry = momentum_bear_score >= 2 and momentum_bear_score[1] < 2 and strategy.position_size >= 0

if long_entry
    if strategy.position_size < 0
        strategy.close("S", comment="flip")
    strategy.entry("L", strategy.long, qty=1, comment="mom 2of3 long")

if short_entry
    if strategy.position_size > 0
        strategy.close("L", comment="flip")
    strategy.entry("S", strategy.short, qty=1, comment="mom 2of3 short")

Overview

PF IES probe 03 - rsi+macd momentum enters long when the bullish score rises through two of three and enters short on the opposite rising edge, flipping the position. Settings change RSI and MACD lengths and the RSI thresholds. Entries are placed on the price chart. It uses a fixed quantity of one and has no stop loss or take profit.

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

Oscillators & momentum

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
RSI Periodint14i_rsi_len
RSI Bullish Levelfloat55i_rsi_bull
RSI Bearish Levelfloat45i_rsi_bear
MACD Fastint12i_macd_fast
MACD Slowint26i_macd_slow
MACD Signalint9i_macd_sig
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

MACD Strategy

by TradersPost
218 stars

This overlay strategy is built around MACD inputs for a fast average, a slow average, and a signal line. Comments say the script keeps MACD values available and can draw a histogram and zero line in a separate pane, with an optional overlay on price. Settings

Strategy v6 Oscillators & momentumMoving averages
Updated 3 months ago · None stated GitHub repository of MACD Strategy

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