Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Pine Script functions with dynamic length

Hello, what is the correct way to use dynamic length in formulas or it is currently not supported?

down_bar = close > hl2[1]
length = barssince(down_bar)

plot(length>1? sma(volume,length):na )

this code returns error
Error: Cannot call `sma` with arguments (series, series); available overloads: sma(series, integer) => series
8 people have
this question