SuperCharting
Sign in Get started Account Open charts

Learn / Guides

Pine Script force_overlay: draw on the price chart from a pane indicator

How force_overlay = true works in Pine Script v5 and v6: which functions take it, a working RSI example that marks signals on the candles, and what stays in the pane.

force_overlay = true lets an indicator that lives in its own pane draw some of its visuals on the main price chart. A script declared with indicator(overlay = false), such as an RSI, can keep its RSI line in the pane and still put buy and sell marks, a background colour or labels on the candles. SuperCharting supports force_overlay for every call that takes it in Pine Script v5 and v6.

Which functions take force_overlay

Takes force_overlayDoes not take it
plot(), plotshape(), plotchar(), plotarrow()fill(): it follows its two plots instead
plotcandle(), plotbar()hline(): always stays in the script's pane
bgcolor()barcolor(): already colours the main chart's bars
label.new(), line.new(), box.new()
polyline.new(), table.new()

Leave it out, or set it to false, and the visual stays where the script's overlay setting puts it. On a script that already has overlay = true, the argument changes nothing.

A working example: RSI in a pane, signals on the candles

//@version=6
indicator("RSI with signals on price", overlay = false)

len = input.int(14, "RSI length")
r   = ta.rsi(close, len)

// In the RSI pane
plot(r, "RSI", color.purple)
hline(70, "Overbought")
hline(30, "Oversold")

// On the price chart
plot(ta.sma(close, 20), "SMA 20", color.orange, force_overlay = true)
plotshape(ta.crossover(r, 30), "RSI up", shape.triangleup, location.belowbar,
     color.green, size = size.small, force_overlay = true)
plotshape(ta.crossunder(r, 70), "RSI down", shape.triangledown, location.abovebar,
     color.red, size = size.small, force_overlay = true)
bgcolor(r > 70 ? color.new(color.red, 90) : na, force_overlay = true)

The RSI line and the two horizontal lines stay in the pane. The 20-period SMA, the triangles and the red background are drawn on the candles and scaled with the price axis.

How it behaves in SuperCharting

How to try it

  1. Open a chart, for example NSE:NIFTY on the 15m interval.
  2. Open the Pine Editor at the bottom of the screen.
  3. Paste the example above and click Add to chart.
  4. The RSI appears in a new pane, and the SMA, triangles and background appear on the candles.

If the script does not compile, the editor shows the line and the error. The free Pine Script checker checks a script without an account, and the Pine Script errors hub explains the common messages.

Frequently asked questions

What does force_overlay do in Pine Script?

It draws one plot, shape, background or drawing on the main price chart while the rest of the indicator stays in its own pane.

Which Pine version supports force_overlay?

Pine Script v5 and v6 accept it. SuperCharting supports it in both.

Why is my hline not moving to the chart?

hline() has no force_overlay argument. Use plot() with a constant value and force_overlay = true instead.

Does force_overlay work with alerts?

Yes. Alerts read the script's values, not where they are drawn, so alertcondition() and alert() work the same whether a plot is in the pane or on the price chart.

Try it on a live chart

SuperCharting is an AI-enabled charting and coding platform in your browser: charts, Pine-compatible scripts with AI Auto-fix, the Strategy Tester, alerts and the screener.

Create a free account More guides