Herrwolf1
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: November 9th, 2020
Contact: TradingView Profile

Identifying :=

I was reading through another script and came across two lines that I don't understand what's happening. I searched the help for ":=" but it didn't return any results. Can someone explain what's happening in the second line? I assume it's storing a value into the last index of an array.

smoothPeriod = 0.0
smoothPeriod:= (0.33 * period) + (0.67 * nz(smoothPeriod[1]))

User avatar
Matthew
Site Admin
Site Admin
Posts: 92
Joined: July 1st, 2020
Location: Australia
Contact: Website Facebook Twitter TradingView Profile

Re: Identifying :=

Hi Herrwolf!

That symbol := means "reassign". So if you declare a variable in your script and then want to change the value of that variable later, you need to use := to reassign the variable.

If you use = twice then the script won't compile and you'll get an error. Hope that helps :)

Return to “Pine Script Q&A”