Page 1 of 1

Undeclared identifier message sar/dmi strategy

Posted: Sat Dec 16, 2023 9:05 am
by seven31
i'm building a strategy using the parabolic sar and DMI, Its my first time so im having a bit of trouble.

//@version=5
strategy(title="SAR ADX", initial_capital=150000, currency= currency.USD, default_qty_type= strategy.percent_of_equity)

// THE variables
sar = ta.sar(sar_acceleration, sar_acceleration, sar_maximum)
dmi = ta.dmi(di_Length, adx_Smoothing)

// Define inputs
sar_acceleration = input.float(0.02, title="SAR Acceleration")
sar_maximum = input.float(0.2, title="SAR Maximum")
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")

i am kind of stuck in the begining, it tells me adx smoothing is an undeclared identifier, i tried all sorts of combinations getting the names exactly the same between the variables and the inputs, but it still gives the same message, can someone tell me what im doing wrong?

Re: Undeclared identifier message sar/dmi strategy

Posted: Sat Dec 16, 2023 1:50 pm
by Kalmb
You need to take the free maystry course (start with inputs BEFORE Variables)
Check the code from the link https://www.tradingview.com/pine-script ... fun_ta.dmi

//@version=5
strategy(title="SAR ADX", initial_capital=150000, currency= currency.USD, default_qty_type= strategy.percent_of_equity)
// Define inputs
sar_acceleration = input.float(0.02, title="SAR Acceleration")
sar_maximum = input.float(0.2, title="SAR Maximum")
len = input.int(17, minval=1, title="di Length")
lensig = input.int(14, title="adx Smoothing", minval=1, maxval=50)

// THE variables
sar = ta.sar(sar_acceleration, sar_acceleration, sar_maximum)
[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")