seven31
Pine Script Rookie
Pine Script Rookie
Posts: 2
Joined: December 16th, 2023

Undeclared identifier message sar/dmi strategy

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?

Kalmb
Pine Script Scholar
Pine Script Scholar
Posts: 8
Joined: February 22nd, 2022

Re: Undeclared identifier message sar/dmi strategy

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")

Return to “Pine Script Q&A”