Outputs & helpers
The constructs that put things on the chart or raise events. mark buy/sell are also what the backtester trades and the scanner matches on the last closed bar.
draw line
draw line(value, color:, title:, width:, style:)
Plot a series as a line on the chart.
| value | series | The per-bar values to plot. |
| color / title / width / style | named | `style: "dashed" | "dotted"`, `width:` in px. |
Returns: chart plot
pulse 1
draw line(ema(close, 20), color: "#38bdf8", title: "EMA 20")
draw area
draw area(value, color:, title:)
Plot a series as a filled area from the zero line.
| value | series | Per-bar values. |
Returns: chart plot
pulse 1
meta(name: "RSI", overlay: false)
draw area(rsi(close, 14), color: "#7c9cff", title: "RSI")
draw steps
draw steps(value, color:, title:)
Plot a series as a step line (holds each value until the next).
| value | series | Per-bar values. |
Returns: chart plot
pulse 1
draw steps(sma(close, 20), title: "SMA steps")
draw dots
draw dots(value, color:, title:)
Plot a series as discrete dots.
| value | series | Per-bar values. |
Returns: chart plot
pulse 1
draw dots(ta.pivotHigh(high, 5, 5), color: "#ef4444", title: "pivots")
draw hist
draw hist(value, color:, title:)
Plot a series as a histogram of bars from the zero line.
| value | series | Per-bar values (often a difference). |
Returns: chart plot
pulse 1
meta(name: "MACD hist", overlay: false)
draw hist(ta.macdFull().histo, title: "histogram")
draw band
draw band(upper, lower, color:, title:)
Fill the area between two series (e.g. Bollinger Bands).
| upper | series | Top edge. |
| lower | series | Bottom edge. |
Returns: chart plot
pulse 1
b = ta.bands(20, 2)
draw band(b.upper, b.lower, color: "rgba(124,156,255,0.15)", title: "BB")
draw level
draw level(y, color:, title:, style:)
A constant horizontal reference line at price/value `y`.
| y | number | The level. |
Returns: chart level
pulse 1
meta(name: "RSI", overlay: false)
draw line(rsi(close, 14), title: "RSI")
draw level(70, color: "#ef4444", title: "overbought")
draw level(30, color: "#22c55e", title: "oversold")
draw marker
draw marker(cond, at:, shape:, color:, text:, size:)
Draw a shape on bars where `cond` is true. Shapes: circle, square, diamond, cross, triangleUp/Down, arrowUp/Down, flag.
| cond | bool | When to place the marker. |
| at | "above" | "below" | number | Position relative to the bar, or an explicit price. |
| shape / color / text / size | named | Appearance. |
Returns: chart markers
pulse 1
draw marker(crossOver(ema(close, 9), ema(close, 21)), at: "below", shape: "triangleUp", color: "#22c55e")
mark buy / sell / note
mark buy|sell|note at <price> "text"
Drop a signal marker. `mark buy`/`sell` are also what the backtester trades and the scanner matches on the last closed bar.
| at <price> | series | Where to anchor it, e.g. `at low` / `at high`. |
| "text" | text? | Optional label baked onto the marker. |
Returns: signal markers
pulse 1
when crossOver(ema(close, 9), ema(close, 21)): mark buy at low "Long"
when crossUnder(ema(close, 9), ema(close, 21)): mark sell at high "Short"
paint bg
paint bg(color)
Tint the chart background on the current bar (usually gated by a condition).
| color | color | An rgba() colour with low opacity works best. |
Returns: background tint
pulse 1
when close > open: paint bg(rgba(34, 197, 94, 0.06))
when close < open: paint bg(rgba(239, 68, 68, 0.06))
paint candles
paint candles(color)
Recolour the candle body on the current bar.
| color | color | The candle colour for this bar. |
Returns: candle tint
pulse 1
when rsi(close, 14) > 70: paint candles(rgba(239, 68, 68, 0.8))
when rsi(close, 14) < 30: paint candles(rgba(34, 197, 94, 0.8))
alert()
alert("message")
Raise an alert event on the current bar — captured in the console today; the live alert-engine bridge lands in a coming release.
| message | text | The alert text. |
Returns: alert event
pulse 1
when crossOver(ema(close, 9), ema(close, 21)): alert("EMA 9 crossed above EMA 21")
onTf()
onTf(timeframe, expr) → series
Evaluate an expression on a higher timeframe, mapping back only COMPLETED bars — strict no-repaint.
| timeframe | text | Higher timeframe, e.g. "4h", "1d". |
| expr | series | Any price / ta.* expression to compute on that timeframe. |
Returns: series (HTF value mapped to chart bars)
pulse 1
htfTrend = onTf("4h", ema(close, 20))
draw line(htfTrend, color: "#a78bfa", title: "4h EMA 20")
nz()
nz(x, replacement?) → number
Replace none / non-finite values with `replacement` (default 0).
| x | number | Value that might be none. |
| replacement | number? | Fallback (default 0). |
Returns: number
pulse 1
draw line(nz(sma(close, 50), close), title: "SMA (close during warmup)")
na()
na(x) → bool
True when x is none / not-a-number (e.g. during an indicator’s warmup).
| x | number | Value to test. |
Returns: bool
pulse 1
when na(sma(close, 50)): mark note at high "warming up"