pine-scriptpine-script-v5

pine script v5 Undeclared identifier 'plot'


good day this is part of my pine script

// Plot MACD components with conditional visibility
plot(macd_active ? macd_line : na, color=color.blue, title="MACD Line", linewidth=2)
plot(macd_active ? signal_line : na, color=color.orange, title="Signal Line", linewidth=2)
plot(macd_active ? histogram : na, style=plot.style_histogram, color=histogram >= 0 ? color.green : color.red, title="Histogram")
plot(0, color=color.gray, title="Zero Line", linewidth=1, style=plot.style_dashed)

I keek getting this error on the last 'plot' in the last string any advice Undeclared identifier 'plot'


Solution

  • plot() does not have a style called plot.style_dashed.

    Possible values are: plot.style_line, plot.style_stepline, plot.style_stepline_diamond, plot.style_histogram, plot.style_cross, plot.style_area, plot.style_columns, plot.style_circles, plot.style_linebr, plot.style_areabr, plot.style_steplinebr.

    If you want a dashed line, you can use hline() instead.

    hline(0, "Zero Line", color.gray, hline.style_dashed, 1)