ScriptingHow toHow to plot a value on its own scale rather than over price

How to plot a value on its own scale rather than over price

Pass overlay = false in the indicator declaration. The script then gets its own scale instead of being drawn against price.

indicator(const string title, const string shorttitle, const bool overlay, const string format, const int precision) → void
indicator("Bar range", "range", false)
plot(high - low, title = "Range", color = color.blue)

overlay is the third parameter, so it can go by position as above, or by name.

indicator("Relative strength", overlay = false)
plot(talib.rsi(close, 14), title = "RSI", color = color.blue)

Every argument of indicator is const. A value from an input function carries the input form, which is wider than const, so you cannot let the reader switch the overlay from the chart.

If one plot should sit over price while the rest do not

The script-wide setting and a single plot’s are separate switches. plot takes a force_overlay argument that sets that one plot’s overlay by itself.

plot(close, title = "Close", force_overlay = true)

Seven functions take it, and no others: plot, plotarrow, plotbar, plotcandle, plotchar, plotshape and bgcolor. barcolor, fill and hline do not.

Rounding the numbers on the scale

indicator also takes format and precision, both const. This edition does not document what values format accepts, so set it only if you already know the value you want.

See Plotting.

Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.
Upgrade