P. Garrison
P. Garrison

Reputation: 19

compilation problem of Undeclared variable error in Pine Script

Good day,

I'm trying to figure out why pine script is being such a finicky beast! I've got a bunch of variables that calculate ema's on various time periods: minutes 1,5,15; hours 1,4 then 1 day,week and month, then divides the total by 8 to get the average value. This holds whether the script version declared is 2 or 3, even changing the syntax on the color and style for version 4 still results in the same error.

Part of it which works fine up to this point is: `

shtma = ema(sht,pers)
    midma = ema(med,perm)
    lngma = ema(lng,perl)
    lngmb = ema(resa,pera)
    lngmc = ema(resb,perb)
    lngmd = ema(resd,perd)
    lngme = ema(resw,perw)
    aa = ema(resx,perx)

    combo = (shtma  + midma  + lngma + lngmb + lngmc + lngmd + lngme + aa) / 8
`

It is only when it gets to the next statement:

plot(combo, style = line, linewidth = 2, transp = 0, color = white)
That throws the "undeclared identified" error - even though you can see it should be declared above. Any suggestions? Thanks!

Upvotes: 1

Views: 46

Answers (1)

G.Lebret
G.Lebret

Reputation: 3088

In pinescript v5, use :

plot(combo, style = plot.style_line, linewidth = 2, color = color.white) 

Upvotes: 1

Related Questions