Appearance
Output
Plots, shapes, levels and fills drawn on the chart, plus alerts and the log.
| Name | Description |
|---|---|
plot() | Draws a series on the chart. |
plotShape() | Draws a marker on every bar where cond is 1. |
plotCandle() | Draws candles (or OHLC bars) from four series, e.g. |
plotVolumeProfile() | A volume profile built by the chart from its own candles: over the visible bars (range: "visible", drawn at the right edge) or per session (range: "session", one histogram per UTC day or week). |
hline() | Draws a horizontal line at a fixed level, e.g. |
fill() | Shades the area between two series, or a series and a level, or two levels (e.g. |
bgcolor() | Tints the background of every bar where cond is 1. |
barcolor() | Recolours the chart's candles on every bar where cond is 1 (TradingView barcolor). |
alert() | Records an alert with a name and a message in the run's journal. |
log() | Writes a line to the run's journal; objects are written as JSON. |
plot()
ts
plot(series: Series, options?: PlotOptions): voidDraws a series on the chart. Call it at the top level, once per line.
Types: Series, PlotOptions
plotShape()
ts
plotShape(cond: BoolSeries | boolean, options?: ShapeOptions): voidDraws a marker on every bar where cond is 1. Pass a series (e.g. ta.crossover(...)); a plain boolean draws nothing.
Types: BoolSeries, ShapeOptions
plotCandle()
ts
plotCandle(open: Series, high: Series, low: Series, close: Series, options?: { title?: string; colorUp?: string; colorDown?: string; wickColor?: string; style?: "candle" | "bar"; pane?: number; display?: "all" | "pane" | "legend" | "none"; }): voidDraws candles (or OHLC bars) from four series, e.g. Heikin Ashi in its own pane or over the price.
Types: Series
plotVolumeProfile()
ts
plotVolumeProfile(options?: { title?: string; range?: "visible" | "session"; session?: "day" | "week"; rows?: number; valueArea?: number; widthPercent?: number; placement?: "right" | "left"; upColor?: string; downColor?: string; vaUpColor?: string; vaDownColor?: string; pocColor?: string; showPoc?: boolean; }): voidA volume profile built by the chart from its own candles: over the visible bars (range: "visible", drawn at the right edge) or per session (range: "session", one histogram per UTC day or week). Rows split each bar's volume evenly across its high-low range, coloured by the bar's direction; the value area holds valueArea percent of the volume around the point of control (POC).
hline()
ts
hline(value: number, options?: { title?: string; color?: string; style?: "solid" | "dashed" | "dotted"; width?: number; pane?: number }): voidDraws a horizontal line at a fixed level, e.g. 70 and 30 on an RSI pane.
fill()
ts
fill(a: Series | number, b: Series | number, options?: { color?: string; colorDown?: string; title?: string; offset?: number }): voidShades the area between two series, or a series and a level, or two levels (e.g. RSI 30..70). With colorDown the shading switches colour where a falls below b (an Ichimoku cloud); offset shifts it like plot's.
Types: Series
bgcolor()
ts
bgcolor(cond: BoolSeries | boolean, options?: { color?: string }): voidTints the background of every bar where cond is 1. Pass a series; a plain boolean draws nothing.
Types: BoolSeries
barcolor()
ts
barcolor(cond: BoolSeries, options: { color: string }): voidRecolours the chart's candles on every bar where cond is 1 (TradingView barcolor). Later calls win on the same bar.
Types: BoolSeries
alert()
ts
alert(name: string, message: string): voidRecords an alert with a name and a message in the run's journal. In AlphaForge, a script alert on the saved script fires on each call (or only on calls with one name) and can reach a webhook. Alerts and log lines together are capped at 2,000 per run.
log()
ts
log(...args: unknown[]): voidWrites a line to the run's journal; objects are written as JSON. Log lines and alerts together are capped at 2,000 per run.
Types
PlotOptions
Options of plot().
| Field | Type | Description |
|---|---|---|
title? | string | legend label (default "plot N") |
color? | string | CSS colour (default grey) |
width? | number | line width in pixels (default 1) |
style? | "line" | "step" | "area" | "histogram" | "columns" | "circles" | "cross" | "baseline" | line, step (stepline), area, histogram (from 0), columns (wide histogram), circles, cross, baseline |
lineStyle? | "solid" | "dashed" | "dotted" | |
colorUp? | string | histogram/columns: colour of values >= 0 / < 0 (e.g. the MACD histogram); baseline: above/below baseValue |
colorDown? | string | |
colorBy? | "sign" | "candle" | what picks colorUp/colorDown: the value's sign (default) or the bar's direction (close >= open), as volume does |
baseValue? | number | the level a baseline plot is coloured above and below |
display? | "all" | "pane" | "legend" | "none" | "all" (default), "pane" (no legend value), "legend" (legend value only, not drawn), "none" |
pane? | number | 0 = price pane (overlay), 1.. = separate panes. In an indicator({ overlay: false }) every plot goes to the indicator's own pane on the chart. |
offset? | number | Shifts the plot by whole bars: positive draws it into the future (e.g. Ichimoku's leading spans), negative into the past. |
palette? | readonly string[] | Per-bar colours: colorIndex picks palette[colorIndex] on each bar (NaN or out of range = color). |
colorIndex? | Series | The series of palette indexes, e.g. ta.calc([ao, ta.change(ao)], (v, d) => (d >= 0 ? 0 : 1)). |
ShapeOptions
Options of plotShape().
| Field | Type | Description |
|---|---|---|
shape? | "triangleUp" | "triangleDown" | "circle" | "square" | "arrowUp" | "arrowDown" | "label" | default "circle" |
location? | "aboveBar" | "belowBar" | "absolute" | default "belowBar" |
color? | string | |
text? | string | |
size? | "tiny" | "small" | "normal" | "large" | |
offset? | number | Draws the marker this many bars back (0 or negative), e.g. -2 to mark a pivot found two bars late. |
