OPEN-SOURCE SCRIPT
ADX +DI/-DI with Buy/Sell Signals

//version=5
indicator("ADX +DI/-DI with Buy/Sell Signals", overlay=true)
// Inputs
adxLength = input.int(14, "ADX Length")
threshold = input.float(25.0, "ADX Threshold")
// Directional Movement
upMove = ta.change(high)
downMove = -ta.change(low)
plusDM = (upMove > downMove and upMove > 0) ? upMove : 0.0
minusDM = (downMove > upMove and downMove > 0) ? downMove : 0.0
// True Range and Smoothed Values
tr = ta.rma(ta.tr, adxLength)
plusDI = 100 * ta.rma(plusDM, adxLength) / tr
minusDI = 100 * ta.rma(minusDM, adxLength) / tr
dx = 100 * math.abs(plusDI - minusDI) / (plusDI + minusDI)
adx = ta.rma(dx, adxLength)
// Buy/Sell Conditions
buySignal = ta.crossover(plusDI, minusDI) and adx > threshold
sellSignal = ta.crossover(minusDI, plusDI) and adx > threshold
// Plot Buy/Sell markers
plotshape(buySignal, title="BUY", location=location.belowbar,
color=color.new(color.lime, 0), style=shape.triangleup, size=size.large, text="BUY")
plotshape(sellSignal, title="SELL", location=location.abovebar,
color=color.new(color.red, 0), style=shape.triangledown, size=size.large, text="SELL")
// Optional ADX + DI lines (hidden by default)
plot(adx, title="ADX", color=color.yellow, linewidth=2, display=display.none)
plot(plusDI, title="+DI", color=color.green, display=display.none)
plot(minusDI, title="-DI", color=color.red, display=display.none)
hline(threshold, "ADX Threshold", color=color.gray, linestyle=hline.style_dotted)
// Alerts
alertcondition(buySignal, title="BUY Alert", message="ADX Buy Signal Triggered")
alertcondition(sellSignal, title="SELL Alert", message="ADX Sell Signal Triggered")
indicator("ADX +DI/-DI with Buy/Sell Signals", overlay=true)
// Inputs
adxLength = input.int(14, "ADX Length")
threshold = input.float(25.0, "ADX Threshold")
// Directional Movement
upMove = ta.change(high)
downMove = -ta.change(low)
plusDM = (upMove > downMove and upMove > 0) ? upMove : 0.0
minusDM = (downMove > upMove and downMove > 0) ? downMove : 0.0
// True Range and Smoothed Values
tr = ta.rma(ta.tr, adxLength)
plusDI = 100 * ta.rma(plusDM, adxLength) / tr
minusDI = 100 * ta.rma(minusDM, adxLength) / tr
dx = 100 * math.abs(plusDI - minusDI) / (plusDI + minusDI)
adx = ta.rma(dx, adxLength)
// Buy/Sell Conditions
buySignal = ta.crossover(plusDI, minusDI) and adx > threshold
sellSignal = ta.crossover(minusDI, plusDI) and adx > threshold
// Plot Buy/Sell markers
plotshape(buySignal, title="BUY", location=location.belowbar,
color=color.new(color.lime, 0), style=shape.triangleup, size=size.large, text="BUY")
plotshape(sellSignal, title="SELL", location=location.abovebar,
color=color.new(color.red, 0), style=shape.triangledown, size=size.large, text="SELL")
// Optional ADX + DI lines (hidden by default)
plot(adx, title="ADX", color=color.yellow, linewidth=2, display=display.none)
plot(plusDI, title="+DI", color=color.green, display=display.none)
plot(minusDI, title="-DI", color=color.red, display=display.none)
hline(threshold, "ADX Threshold", color=color.gray, linestyle=hline.style_dotted)
// Alerts
alertcondition(buySignal, title="BUY Alert", message="ADX Buy Signal Triggered")
alertcondition(sellSignal, title="SELL Alert", message="ADX Sell Signal Triggered")
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.