Strategy · Pine Script v6 · On the chart

PF IES probe 01 - adx regime

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

PF IES probe 01 is a Pine Script v6 strategy that calculates ADX with a custom DI chain using ta.rma smoothing and manual plus/minus DM flow.

View on GitHub

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

87 lines of Pine Script v6 from validation/composite-ies-adx-regime-classify-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 01 — manual ADX/DI chain + ATR-ratio regime classification
//
// Purpose: isolate the IES integration probe family's bespoke regime detector.
// That family does NOT use the built-in `ta.dmi`; instead it rolls its own
// DI flow through `ta.rma`:
//
//   plus_dm  = max(high - high[1], 0); minus_dm = max(low[1] - low, 0)
//   if plus_dm > minus_dm: minus_dm := 0  else: plus_dm := 0
//   smooth_tr/plus/minus = ta.rma(...,14)
//   plus_di / minus_di / dx (DI-sum normalisation) → adx = ta.rma(dx, 14)
//
// It then classifies regime ∈ {0,1,2,3} from `adx >= 25` and an ATR-ratio
// gate (`atr(14) / sma(atr(14),42)` against 1.4 / 0.6). That ratio compares
// current ATR to a 42-bar SMA of ATR — a TA-on-TA chain that often diverges
// across engines on the early bars when the inner ATR is still warming up.
//
// This probe keeps ONLY that calculation surface and entries on the rising
// edge of `regime == 1` (trending). Exits when `regime != 1`. If the engine
// disagrees here, the IES regime gate (which feeds bias_score, regime_size_mult,
// adaptive stop multiplier, and the +2 trending bonus to bull_total) is the
// numerical edge to chase.
//
// 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 01 - adx regime", shorttitle="IES_p01_REG", 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_adx_len   = input.int(14,   "ADX Period",          minval=5,  maxval=30)
float i_adx_trend = input.float(25, "Trend Threshold",     minval=15, maxval=40)
int   i_atr_len   = input.int(14,   "ATR Period",          minval=5,  maxval=30)
float i_vol_exp   = input.float(1.4,"Volatility Expansion",minval=1.1,maxval=2.0, step=0.1)
float i_vol_con   = input.float(0.6,"Volatility Contraction",minval=0.3,maxval=0.9, step=0.1)

// ---- IES's exact f_adx_calc UDF ------------------------------------
f_adx_calc(int len) =>
    float tr_val   = ta.tr(true)
    float plus_dm  = math.max(high - high[1], 0)
    float minus_dm = math.max(low[1] - low, 0)
    if plus_dm > minus_dm
        minus_dm := 0
    else
        plus_dm := 0
    float smooth_tr    = ta.rma(tr_val,   len)
    float smooth_plus  = ta.rma(plus_dm,  len)
    float smooth_minus = ta.rma(minus_dm, len)
    float plus_di  = smooth_tr > 0 ? 100 * smooth_plus  / smooth_tr : 0
    float minus_di = smooth_tr > 0 ? 100 * smooth_minus / smooth_tr : 0
    float di_sum   = plus_di + minus_di
    float dx       = di_sum > 0 ? 100 * math.abs(plus_di - minus_di) / di_sum : 0
    float adx_val  = ta.rma(dx, len)
    [adx_val, plus_di, minus_di]

[adx, plus_di, minus_di] = f_adx_calc(i_adx_len)

// ---- ATR-ratio volatility gate -------------------------------------
float atr_val   = ta.atr(i_atr_len)
float atr_ma    = ta.sma(atr_val, i_atr_len * 3)
float vol_ratio = atr_ma > 0 ? atr_val / atr_ma : 1.0

// ---- regime classification (IES exact ladder) ----------------------
int regime = 0
if vol_ratio >= i_vol_exp and adx < i_adx_trend
    regime := 3
else if adx >= i_adx_trend
    regime := 1
else if vol_ratio <= i_vol_con
    regime := 2

bool trending_regime = regime == 1

// ---- trivial entry on rising edge of trending regime ---------------
bool long_entry = trending_regime and not trending_regime[1] and strategy.position_size == 0
bool long_exit  = not trending_regime and strategy.position_size > 0

if long_entry
    strategy.entry("L", strategy.long, qty=1, comment="trending ON")
if long_exit
    strategy.close("L", comment="trending OFF")

Overview

PF IES probe 01 - adx regime applies an ATR-ratio volatility gate comparing current ATR to its 42-period SMA to classify regimes into four categories based on ADX strength and volatility expansion or contraction thresholds. The strategy enters on regime 1 (trending) and exits on regime change. It plots entries and exits directly on the price chart with overlay enabled. Inputs adjust ADX length, trend threshold, ATR length, and volatility limits. The probe isolates bespoke regime detection for IES integration testing.

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, Volatility & bands, Oscillators & momentum

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
ADX Periodint14i_adx_len
Trend Thresholdfloat25i_adx_trend
ATR Periodint14i_atr_len
Volatility Expansionfloat1.4i_vol_exp
Volatility Contractionfloat0.6i_vol_con
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

106 stars

This trading strategy combines three Exponential Moving Averages (8, 14, and 50 periods by default) with Stochastic RSI and Average True Range (ATR). It enters a long position when EMA 1 is above EMA 2, EMA 2 is above EMA 3, and the Stochastic RSI %K line cros

Strategy v4 TrendOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 3 x EMA + Stochastic RSI + ATR

Momentum Rider DAILY FINAL

by greenpeas007
58 stars

This strategy combines exponential moving averages (EMA 9, 21, 50), RSI, MACD, and Supertrend indicators to enter long positions. It triggers trades using six dynamic setups based on momentum breakouts, EMA crossovers, and pullbacks. Position sizing is compute

Strategy v6 TrendOscillators & momentum Repaints
Updated 4 months ago · Custom licence GitHub repository of Momentum Rider DAILY FINAL
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

CombinedBinHAndClucV6

by viktors1982
36 stars

CombinedBinHAndClucV6 is a trading strategy based on the popular BinHV45 and ClucMay72018 algorithms. It calculates dual Bollinger Bands, Exponential Moving Averages, Relative Strength Index, Average True Range, and volume metrics across primary and one-hour h

Strategy v4 Volatility & bandsOscillators & momentum Repaints
Updated 2 years ago · None stated GitHub repository of CombinedBinHAndClucV6
27 stars

LuxAlgo Hybrid Gold Scalper is a price-chart strategy aimed at gold. It stacks a fast, slow, trend and 200-period bias EMA to mark trend direction, then filters strength with RSI, ADX and an intraday VWAP. Swing highs and lows are marked from pivot length. Set

Strategy v5 TrendOscillators & momentum
Updated 5 months ago · None stated GitHub repository of LuxAlgo Hybrid Gold Scalper

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