Strategy · Pine Script v6 · On the chart

VCP probe 03 - rsi smooth divergence

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

The strategy detects smoothed RSI divergences on the price chart.

View on GitHub

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

57 lines of Pine Script v6 from validation/composite-vcp-rsi-smooth-divergence-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
//
// VCP probe 03 — smoothed-RSI divergence detection
//
// Purpose: isolate the momentum half of the VCP integration probe family.
// That family smooths RSI through an EMA(3) and then derives both
// ``momBullish`` / ``momBearish`` regime flags AND a divergence pair
// ``rsiDivBull`` / ``rsiDivBear`` keyed off ``close[5]`` and
// ``rsiSmooth[5]``. That 5-bar history-reference of an EMA-of-RSI is the
// most-likely place for a numerical drift to creep in — even a single
// epsilon error in the EMA(3) seed shifts every divergence event by a bar.
//
// This probe routes a trivial entry/exit through ONLY the smoothed-RSI
// divergence pair, with the EXACT VCP expressions and the VCP defaults
// (``rsiLength = 14``, EMA smoothing length 3, divergence lookback 5,
// ``rsiOverbought = 70`` / ``rsiOversold = 30`` not used here — only
// the 60/40 divergence thresholds). Any TV/engine drift here is
// attributable to ``ta.ema(ta.rsi(close, 14), 3)`` precision and the
// 5-bar history references the divergence formula uses, NOT to other
// VCP filters.
//
// Trade shape: long-only, pyramiding=1. Enter long on bullish RSI
// divergence (smoothed RSI < 40 with rising RSI vs falling 5-bar
// price reference, EXACT VCP wording flipped to a ``close > close[5]``
// constructive divergence). Close the long on bearish RSI divergence
// (smoothed RSI > 60 with falling RSI vs rising 5-bar price reference,
// VCP's exact ``rsiDivBear``).
//
// 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("VCP probe 03 - rsi smooth divergence", shorttitle="VCP_p03",
     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 (mirror VCP defaults) ----------------------------------
int i_rsi = input.int(14, "RSI Length", minval=5, maxval=30)

// ---- smoothed RSI — IDENTICAL formula to VCP -----------------------
float rsiValue  = ta.rsi(close, i_rsi)
float rsiSmooth = ta.ema(rsiValue, 3)

// ---- divergence flags — IDENTICAL expressions to VCP --------------
bool rsiDivBull = rsiSmooth < 40 and close > close[5] and rsiSmooth > rsiSmooth[5]
bool rsiDivBear = rsiSmooth > 60 and close < close[5] and rsiSmooth < rsiSmooth[5]

// ---- trivial entry / exit ------------------------------------------
if rsiDivBull and strategy.position_size == 0
    strategy.entry("L", strategy.long, qty=1, comment="rsi div bull")

if rsiDivBear and strategy.position_size > 0
    strategy.close("L", comment="rsi div bear exit")

Overview

VCP probe 03 - rsi smooth divergence calculates smoothed RSI as the EMA of 3 applied to the 14-period RSI of close. Bullish divergence signals when smoothed RSI is below 40, with smoothed RSI rising over five bars while close exceeds close[5]. Bearish signals trigger when smoothed RSI exceeds 60, with smoothed RSI falling over five bars while close is below close[5]. The strategy enters long positions on bullish divergence and closes longs on bearish divergence. It uses fixed position sizing of one unit with pyramiding enabled and no stop loss or take profit. The primary input adjusts the RSI period length between 5 and 30. Signals appear directly on the price chart.

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, Divergence, SMC / ICT / price action

Markets

Crypto

Timeframes

M15-H1

Risk Notes

  • The strategy can add several entries in the same direction
  • 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 Lengthint14i_rsi
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 strategy combines fractal-based supply and demand order blocks with Awesome Oscillator divergence detection. It generates long signals when price interacts with a demand zone alongside a confirmed bullish divergence, and short signals at supply zones with

Strategy v5 SMC / ICT / price actionOscillators & momentum
Updated 5 weeks ago · None stated GitHub repository of Combined Strategy - Supply/Demand + AO Divergence

ETH_buy_3commas

by hasnocool
106 stars

This strategy overlays a Cipher B style WaveTrend study on the price chart and is titled for Ethereum buy alerts aimed at 3Commas. It calculates a WaveTrend channel and a short moving average, and can mark buy, sell, gold, and divergence dots. Settings change

Strategy v4 Oscillators & momentumDivergence
Updated 2 years ago · GPL-3.0 GitHub repository of ETH_buy_3commas
105 stars

This overlay strategy looks for gold scalps from break of structure and change of character. It enters long when a bullish break, a bullish character change, and an optional volume filter align, and short on the opposite set. Optional RSI levels can block trad

Strategy v6 SMC / ICT / price actionOscillators & momentum Repaints
57 stars

This strategy identifies trend reversals through market structure changes (CHoCH) filtered by MACD momentum. It initiates long positions on bullish structure breaks when MACD is positive and above its signal line, and short positions on bearish breaks when MAC

Strategy v6 SMC / ICT / price actionOscillators & momentum Repaints
Updated 1 year ago · Apache-2.0 GitHub repository of Market Structure MACD 4H + Trailing
43 stars

Donald - AI Futures is a price-chart strategy that estimates inner and outer high-low zones and a smoothed close with rational quadratic kernel regression. It builds bullish and bearish momentum signals, optionally compares volume with a volume-weighted moving

Strategy v5 Oscillators & momentumSMC / ICT / price action Repaints
Updated 2 years ago · None stated GitHub repository of Donald - AI Futures

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