How to pinescript plot values from an array

Viewed 2080

Trying to plot values from an array but I find needing to plot each value separately. How do you create a series to plot this?

// © SKnight79

//@version=4
study("My Script")

pma1 = array.new_float(5,0)

array.push(pma1, security(syminfo.tickerid, "", (ema(close, 10 - 1) * (10 - 1) + close * 1) / 10))
array.push(pma1, security(syminfo.tickerid, "", (ema(close, 10 - 1) * (10 - 2) + close * 2) / 10))
array.push(pma1, security(syminfo.tickerid, "", (ema(close, 10 - 1) * (10 - 3) + close * 3) / 10))
array.push(pma1, security(syminfo.tickerid, "", (ema(close, 10 - 1) * (10 - 3) + close * 3) / 10))
array.push(pma1, security(syminfo.tickerid, "", (ema(close, 10 - 1) * (10 - 5) + close * 5) / 10))

plot(array.get(pma1,0), title="MA 1 Forecast", color=color.red, linewidth=1, style=plot.style_circles, offset=1, show_last=1)
plot(array.get(pma1,1), title="MA 2 Forecast", color=color.red, linewidth=1, style=plot.style_circles, offset=2, show_last=1)
plot(array.get(pma1,2), title="MA 3 Forecast", color=color.red, linewidth=1, style=plot.style_circles, offset=3, show_last=1)
plot(array.get(pma1,3), title="MA 4 Forecast", color=color.red, linewidth=1, style=plot.style_circles, offset=4, show_last=1)
plot(array.get(pma1,4), title="MA 5 Forecast", color=color.red, linewidth=1, style=plot.style_circles, offset=5, show_last=1)
0 Answers
Related