Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to make a PineScript V5 Strategy with ADX and RSI But keep receiving the same error

It just seems that I can't figure out the correct script for my strategy, which is the following:

  • Buy signal when the ADX is above 46 and at the same time the RSI is oversold at or below 20

Works way better in Daily timeframe, get less signals but way more effective, the script is this:

//@version=5
strategy("Estrategia Long Only")
// Definir el indicador ADX
len = input(14, title="ADX Length")
th = input(44, title="ADX Threshold")
adx_val = ta.adx(high, low, close, len)
// Definir el indicador RSI
rsi_len = input(14, title="RSI Length")
rsi_buy = input(20, title="RSI Buy Threshold")
rsi_sell = input(35, title="RSI Sell Threshold")
rsi_val = ta.rsi(close, rsi_len)
// Generar señales de compra
adx_above_th = adx_val > th
rsi_above_buy = rsi_val >= rsi_buy and rsi_val < rsi_sell
buy_signal = adx_above_th and rsi_above_buy
// Entradas largas
if buy_signal
   strategy.entry("Long", strategy.long)
// Plotting
 plotshape(buy_signal, "Buy", shape.triangleup, location.belowbar, color.green, size=size.small)

But I Keep receiving this error:

Error at 10:11 Could not find function or function reference 'ta.adx'

I try importing values from other indicators because seems like the problem is in the ADX indicator, but doesn't seem to work out.

like image 926
Esteban Guillen Avatar asked Dec 12 '25 11:12

Esteban Guillen


1 Answers

There is no ta.adx() function as the error message tells you.

You should use the ta.dmi() to get the adx value.

len = input.int(17, minval=1, title="DI Length")
lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50)
[diplus, diminus, adx] = ta.dmi(len, lensig)
plot(adx, color=color.red, title="ADX")
plot(diplus, color=color.blue, title="+DI")
plot(diminus, color=color.orange, title="-DI")
like image 105
vitruvius Avatar answered Dec 15 '25 03:12

vitruvius



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!