//@version=6
indicator("ADX + LuxAlgo Ultimate RSI Buy/Sell (Filtered)", overlay=true)
//--------------------------------------------------
// INPUTS
//--------------------------------------------------
// ADX settings
adxLength = [Link](14, "ADX Length")
adxLevel = [Link](25, "ADX Threshold (X)")
// LuxAlgo RSI settings
rsiLength = [Link](14, "LuxAlgo RSI Length")
signalLen = [Link](14, "LuxAlgo Signal Length")
//--------------------------------------------------
// ADX CALCULATION (v6 CORRECT)
//--------------------------------------------------
[_, _, adxValue] = [Link](adxLength, adxLength)
//--------------------------------------------------
// LuxAlgo Ultimate RSI (CORE LOGIC)
//--------------------------------------------------
upper = [Link](close, rsiLength)
lower = [Link](close, rsiLength)
rng = upper - lower
d = close - close[1]
diff = upper > upper[1] ? rng :
lower < lower[1] ? -rng :
d
num = [Link](diff, rsiLength)
den = [Link]([Link](diff), rsiLength)
arsi = num / den * 50 + 50
signal = [Link](arsi, signalLen)
//--------------------------------------------------
// CROSS CALCULATIONS (GLOBAL)
//--------------------------------------------------
rsiCrossUp = [Link](arsi, signal)
signalCrossUp = [Link](signal, arsi)
//--------------------------------------------------
// ADX GATE
//--------------------------------------------------
adxActive = adxValue > adxLevel
//--------------------------------------------------
// FINAL SIGNALS (WITH RSI LOCATION FILTER)
//--------------------------------------------------
buySignal = adxActive and rsiCrossUp and arsi <= 50
sellSignal = adxActive and signalCrossUp and arsi >= 50
//--------------------------------------------------
// PLOTS
//--------------------------------------------------
plotshape(
buySignal,
title="BUY",
style=[Link],
location=[Link],
color=[Link],
size=[Link],
text="BUY"
)
plotshape(
sellSignal,
title="SELL",
style=[Link],
location=[Link],
color=[Link],
size=[Link],
text="SELL"
)
//--------------------------------------------------
// ALERTS
//--------------------------------------------------
alertcondition(buySignal, "BUY Signal",
"ADX > X and LuxAlgo RSI cross UP below/equal 50")
alertcondition(sellSignal, "SELL Signal",
"ADX > X and LuxAlgo RSI signal cross UP above/equal 50")