Strategy · Pine Script v6 · On the chart

VCP probe 06 - adx regime

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

This strategy isolates and tests manual directional movement and ADX calculations plotted directly on the main price chart.

View on GitHub

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

73 lines of Pine Script v6 from validation/composite-vcp-manual-adx-regime-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 06 — manual ADX regime detection
//
// Purpose: isolate the regime-filter half of the VCP integration probe
// family. That family does NOT use ``ta.dmi`` — it builds DI/ADX BY HAND
// from ``ta.change(high)`` /
// ``ta.change(low)`` plus a chain of ``ta.rma`` smoothings on plusDM /
// minusDM / true range / dx. That manual chain is a likely source of
// TV/engine drift because:
//   (1) ``ta.change(high)`` produces ``na`` on bar 0; the plusDM /
//       minusDM ternaries explicitly carry the ``na`` (``na(upMove) ?
//       na : ...``);
//   (2) ``ta.rma`` is Wilder's smoothing (alpha = 1/length), which is
//       seeded differently across implementations (some use SMA seed,
//       some use first-non-na, some use 0);
//   (3) the ``adxValue = ta.rma(dx, adxLen)`` final pass adds another
//       length of warm-up, so any seed drift compounds.
// VCP then derives ``regime.isTrending = adxValue > 25`` and
// ``regime.trend = plusDI > minusDI ? 1 : -1`` and uses both to gate
// long/short entries via ``regimeAllowsLong`` / ``regimeAllowsShort``.
//
// This probe routes a trivial entry/exit through ONLY VCP's manual
// ADX. Any TV/engine drift here is attributable to the
// ``ta.rma``-of-``ta.tr`` / DI / DX / ADX chain at length 14, NOT
// to other VCP filters.
//
// Trade shape: long-only, pyramiding=1. Enter long on the bar that
// regime FIRST becomes "trending bull" (``isTrending and trend > 0``
// rising-edge). Close the long when the regime exits "trending bull".
//
// 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 06 - adx regime", shorttitle="VCP_p06",
     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)

// ---- ATR for the volatility ratio (literal 14, matches VCP) -------
float atrVal = ta.atr(14)

// ---- Manual ADX — IDENTICAL formula to VCP lines 419-428 ----------
int adxLen = 14
float upMove   = ta.change(high)
float downMove = -ta.change(low)
float plusDM   = na(upMove)   ? na : (upMove   > downMove and upMove   > 0 ? upMove   : 0)
float minusDM  = na(downMove) ? na : (downMove > upMove   and downMove > 0 ? downMove : 0)
float trueRange = ta.rma(ta.tr, adxLen)
float plusDI    = 100 * ta.rma(plusDM,  adxLen) / trueRange
float minusDI   = 100 * ta.rma(minusDM, adxLen) / trueRange
float dx        = 100 * math.abs(plusDI - minusDI) / (plusDI + minusDI)
float adxValue  = ta.rma(dx, adxLen)

bool isTrending = adxValue > 25
int  trend      = plusDI > minusDI ? 1 : -1
float volatility = atrVal / close * 100

// ---- regime rising / falling edge ----------------------------------
bool trendingBull = isTrending and trend > 0
bool regimeBullStart = trendingBull and not trendingBull[1]
bool regimeBullEnd   = not trendingBull and trendingBull[1]

// ---- trivial entry / exit ------------------------------------------
if regimeBullStart and strategy.position_size == 0
    strategy.entry("L", strategy.long, qty=1, comment="adx trending-bull start")

if regimeBullEnd and strategy.position_size > 0
    strategy.close("L", comment="adx trending-bull end exit")

Overview

VCP probe 06 - adx regime constructs plusDI, minusDI, and ADX without using built-in indicators, entering a long position when ADX exceeds 25 in an uptrend and closing the trade when the regime ends. It lacks defined stop loss or take profit orders.

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

Trend, Oscillators & momentum

Markets

Crypto

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