// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// PF probe 32 — Supertrend direction + ADX-strength filter
// Purpose: parity test for ta.supertrend() tuple-return (value+direction)
// combined with ta.dmi() ADX gate.
//
//@version=6
strategy("Supertrend ADX Filter", overlay=true, initial_capital=1000000, process_orders_on_close=false, pyramiding=1, commission_type=strategy.commission.percent, commission_value=0, slippage=0, default_qty_type=strategy.fixed, default_qty_value=1)
// === Inputs ===
stFactor = input.float(3.0, "Supertrend Factor", step=0.1)
stPeriod = input.int(10, "Supertrend ATR Period", minval=1)
diLen = input.int(14, "DI Length", minval=1)
adxSmooth = input.int(14, "ADX Smoothing", minval=1)
adxThresh = input.int(20, "ADX Threshold")
// === Supertrend (tuple return) ===
[stValue, stDirection] = ta.supertrend(stFactor, stPeriod)
// === DMI (triple tuple return) ===
[diPlus, diMinus, adxVal] = ta.dmi(diLen, adxSmooth)
// === Combined signals ===
// Supertrend direction change + ADX confirms trend strength
stBull = stDirection < 0
stBear = stDirection > 0
adxStrong = adxVal > adxThresh
longCond = stBull and not stBull[1] and adxStrong
shortCond = stBear and not stBear[1] and adxStrong
if longCond
strategy.entry("Long", strategy.long)
if shortCond
strategy.entry("Short", strategy.short)
// === Exit on supertrend flip ===
if strategy.position_size > 0 and stBear
strategy.close("Long")
if strategy.position_size < 0 and stBull
strategy.close("Short")
plot(stValue, "Supertrend", color=stBull ? color.green : color.red, linewidth=2)