OPEN-SOURCE SCRIPT

Parabolic SAR y ADX Strategy

//version=6
indicator("Parabolic SAR y ADX Strategy", overlay=true)

// Parámetros del Parabolic SAR
psar_start = input.float(0.02, title="PSAR Factor Inicial", step=0.01)
psar_increment = input.float(0.02, title="PSAR Incremento", step=0.01)
psar_max = input.float(0.2, title="PSAR Máximo", step=0.01)

// Parámetros del ADX
adx_length = input.int(14, title="Período ADX")
adx_smoothing = input.int(14, title="Suavización ADX", minval=1)
adx_threshold = input.float(20, title="Nivel de referencia ADX", step=1)

// Cálculo del Parabolic SAR
psar = ta.sar(psar_start, psar_increment, psar_max)

// Cálculo del ADX y direcciones (+DI y -DI)
[plus_di, minus_di, adx] = ta.dmi(adx_length, adxSmoothing=adx_smoothing)

// Condiciones de Compra y Venta
long_condition = (adx > adx_threshold) and (close > psar)
short_condition = (adx > adx_threshold) and (close < psar)

// Dibujar señales en el gráfico
plotshape(series=long_condition, title="Compra", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=short_condition, title="Venta", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// Mostrar PSAR en el gráfico
plot(psar, color=color.blue, title="Parabolic SAR")
Candlestick analysisOscillatorsPine utilities

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer