Skip to content

Output ​

Plots, shapes, levels and fills drawn on the chart, plus alerts and the log.

NameDescription
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): void

Draws 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): void

Draws 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"; }): void

Draws 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; }): void

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). 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 }): void

Draws 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 }): void

Shades 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 }): void

Tints 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 }): void

Recolours 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): void

Records 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[]): void

Writes 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().

FieldTypeDescription
title?stringlegend label (default "plot N")
color?stringCSS colour (default grey)
width?numberline 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?stringhistogram/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?numberthe 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?number0 = price pane (overlay), 1.. = separate panes. In an indicator({ overlay: false }) every plot goes to the indicator's own pane on the chart.
offset?numberShifts 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?SeriesThe series of palette indexes, e.g. ta.calc([ao, ta.change(ao)], (v, d) => (d >= 0 ? 0 : 1)).

ShapeOptions ​

Options of plotShape().

FieldTypeDescription
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?numberDraws the marker this many bars back (0 or negative), e.g. -2 to mark a pivot found two bars late.

AlphaScript language v0.1 · runtime 0.2.0