Strategy · Pine Script v6 · On the chart

PF Probe 4EMA RSI Integration

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

PF Probe 4EMA RSI Integration is an overlay strategy combining a four Exponential Moving Average (EMA) stack filter with RSI pullback logic and a fixed bar-count exit.

View on GitHub

GitHub stars3on the repository
Pine versionv6current
Lines of code99
Settings10inputs
LicenceApache-2.0
Last update4 days ago20 Nov 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

99 lines of Pine Script v6 from validation/composite-4emarsi-integration-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 4ema-rsi-probe-integration — quad-EMA + RSI pullback + bar window
// Clean-room: written from validation goal, not from source.
//
// Purpose: composes the cross-surface combination of the four-EMA stack
// (probe 01) and the RSI shallow-pullback latch (probe 02) plus the
// fixed-bar forced-exit counter from probe 03. The session-window gate
// from probe 03 is intentionally NOT composed in (binary session test
// stays standalone in probe 03). Original deep RSI bands (dip < 40,
// recover > 50) almost never co-occur with a same-bar bullish four-EMA
// stack on 15m crypto — by the time RSI dips that deep the trend has
// flipped — so this integration uses a shallow pullback band (dip
// below ~48, recover above ~52) that triggers far more frequently
// inside an existing stack regime. The engine surfaces under test are
// the stacking predicate, the var-bool RSI arm-and-fire latch, and
// the var-int bars-in-trade counter that closes the trade at exactly N.
//
// Validation goal: bit-exact trade list against TradingView's broker
// emulator on the reference 15-minute ETH-USDT-USDT feed. Long when
// stack is bullish AND RSI long-pullback fires; short symmetric;
// forced exit after N bars regardless of state.
//
// 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 4ema-rsi-probe-integration", shorttitle="PF_4emaINT",
     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_xs = input.int(8,   "EMA xs length", minval=2)
int    i_s  = input.int(21,  "EMA s length",  minval=3)
int    i_m  = input.int(55,  "EMA m length",  minval=5)
int    i_l  = input.int(200, "EMA l length",  minval=10)
int    i_rsi_len     = input.int(14,   "RSI length",  minval=2)
float  i_dip_lo      = input.float(48, "Long pullback band",  minval=10, maxval=50)
float  i_pop_lo      = input.float(52, "Long recovery line",  minval=40, maxval=70)
float  i_dip_hi      = input.float(52, "Short pullback band", minval=50, maxval=90)
float  i_pop_hi      = input.float(48, "Short recovery line", minval=30, maxval=60)
int    i_expiry_bars = input.int(8,    "Forced exit after N bars", minval=1)

// ---- four-EMA fan + stack-order predicates -------------------------
float ema_xs = ta.ema(close, i_xs)
float ema_s  = ta.ema(close, i_s)
float ema_m  = ta.ema(close, i_m)
float ema_l  = ta.ema(close, i_l)

bool stack_bull = ema_xs > ema_s and ema_s > ema_m and ema_m > ema_l
bool stack_bear = ema_xs < ema_s and ema_s < ema_m and ema_m < ema_l

// ---- RSI arm-and-fire latches -------------------------------------
float r = ta.rsi(close, i_rsi_len)

var bool long_armed  = false
var bool short_armed = false

if r < i_dip_lo
    long_armed := true
if r > i_dip_hi
    short_armed := true

bool long_fire  = long_armed  and ta.crossover(r,  i_pop_lo)
bool short_fire = short_armed and ta.crossunder(r, i_pop_hi)

if long_fire
    long_armed := false
if short_fire
    short_armed := false

// ---- composed entry signals ---------------------------------------
bool go_long  = stack_bull and long_fire
bool go_short = stack_bear and short_fire

// ---- bars-in-trade counter ----------------------------------------
var int bars_in_trade = 0
if strategy.position_size != 0
    bars_in_trade += 1
else
    bars_in_trade := 0

bool expiry_due = strategy.position_size != 0 and bars_in_trade >= i_expiry_bars

// ---- order routing ------------------------------------------------
// Allow direction flips (long when flat or short, short when flat or long)
// so the integration trade list stays dense enough for parity comparison.
if go_long and strategy.position_size <= 0
    strategy.entry("L", strategy.long, qty=1, comment="integ long")

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

if expiry_due
    strategy.close_all(comment="integ bar expiry")

Overview

A long position enters when the four EMAs are stacked in bullish alignment and an RSI shallow pullback arms and fires above a recovery line. A short position enters symmetrically during a bearish EMA stack. Trades exit unconditionally after a configurable number of bars without using traditional stop loss orders.

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

  • 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
EMA xs lengthint8i_xs
EMA s lengthint21i_s
EMA m lengthint55i_m
EMA l lengthint200i_l
RSI lengthint14i_rsi_len
Long pullback bandfloat48i_dip_lo
Long recovery linefloat52i_pop_lo
Short pullback bandfloat52i_dip_hi
Short recovery linefloat48i_pop_hi
Forced exit after N barsint8i_expiry_bars
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

368 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 3 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 4 years ago · Custom licence GitHub repository of Acrypto - Weighted Strategy

This strategy combines Arnaud Legoux Moving Average percentage price change calculations with an adaptive Gaussian Moving Average to generate trend-following signals. Long and short entries are triggered when the ALMA change calculation crosses above or below

Strategy v5 Moving averagesOscillators & momentum
Updated 2 months ago · None stated GitHub repository of ESM2024 - ALMA Smoothed Gaussian Moving Average
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 4 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

SMA RSI Strategy

by PythonForForex
64 stars

This strategy evaluates simple moving averages and the Relative Strength Index to generate trading signals. It calculates a 10-period SMA, a 30-period SMA, and a 14-period RSI. Long positions are entered when the fast SMA crosses above the slow SMA while RSI i

Strategy v5 TrendOscillators & momentum
Updated 4 years ago · None stated GitHub repository of SMA RSI 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