Skip to content

Charting

HaasScript gives you full control over what's drawn on the chart — lines, candlesticks, histograms, shapes, zones, volume bars, and more.

Charting Rules

  1. Charts work with an index. Index 0 is the main plot. A positive index positions below the main plot, a negative index above.
  2. Index -1 is reserved for the default signal bar — no lines or styling allowed there.
  3. Each index can have at most 1 candlestick chart and unlimited data lines.

Plotting A Line

Creating a line requires a chart index, a name, and a value. The 4th parameter is optional — it can be a color string or a LineOptions object.

Plot(1, 'BTCUSD', ClosePrices(), SkyBlue)

Plot() returns a line guid that you can use with other plotting commands to change the line's style.

LineOptions

LineOptions() lets you control every aspect of a line's appearance:

Parameter Description
color Line color.
style Line style: Spiked, Smooth, Step, and others.
deco Line decoration: Solid, Dashed, Dotted.
width Line width.
offset Shift data points by x candles (positive = forward, negative = backward).
side Axis side to snap to (LeftAxis / RightAxis).
id Unique identifier for the line.
behind If true, the line is drawn behind the price chart.
ignoreOnAxis If true, the line is excluded from y-axis range calculation.
drawTrailingLine If true, a dotted line extends from the last data point to the y-axis.
Plot(1, 'BTCUSD', ClosePrices(), {style=Smooth, color=Yellow})
Plot(1, 'BTCUSD', ClosePrices(), LineOptions(Yellow, Smooth))

Candlestick Charts

PlotPrice

Creates a candlestick chart for a given market. Customize the candle colors, fills, and marking colors.

PlotPrice(0, 'BINANCE_BTC_USDT_')
PlotPrice(0, 'BINANCE_BTC_USDT_', 15, CandleStick, Green, true, Red, true)  -- 15min interval

ChartSetOptions

Controls chart-level settings like title, height, and price plot style. A height below 1 is treated as a percentage (0.5 = 50%).

ChartSetOptions(1, "Binance ETH/USD", 0.5)

PlotVolume

Creates volume bars on a chart index, with separate colors for up/down candles.

PlotVolume(0, Green, Red, true, true)

PlotSignalBar / PlotSignalEnum

Creates a small signal bar chart. PlotSignalEnum takes a signal constant and colors the bar automatically based on the signal.

PlotSignalBar(0, Lime)
PlotSignalEnum(1, signal)  -- passes through the signal for continuation

Line Styles

Once you have a line guid from Plot(), you can change its appearance:

PlotCircle

Renders the line as circles.

local line = Plot(1, 'BTCUSD', ClosePrices())
PlotCircle(line, SkyBlue)  -- with fill color

PlotBars

Renders the line as bars extending from a base value (default: 0).

PlotBars(line, 0, SkyBlue(20))  -- bars from 0, with inner fill

PlotHistogram

Renders the line as a histogram with separate colors for positive and negative bars.

PlotHistogram(line, Red, true)  -- negative bars in red, fill raising bars

PlotDoubleColor

Changes the line color based on whether the value is above or below a threshold.

PlotDoubleColor(line, 0, Red, SkyBlue(20))  -- below 0 = red, with fill

PlotShapes

Changes the line into a specific shape (cross, diamond, arrow, etc.).

PlotShapes(line, ShapeCross, Yellow)

Multi-Line Charts

Combine two or more lines into a single visual:

PlotBands

Fills the area between two lines with a color.

local upper = Plot(0, 'Upper', bbands.upper)
local lower = Plot(0, 'Lower', bbands.lower)
PlotBands(upper, lower, SkyBlue(10))

PlotCloud

Creates a cloud with double colors between two lines. The color switches depending on which line is on top.

PlotCloud(line1, line2, 30)

PlotStackedArea

Creates a stacked area chart from multiple line guids.

PlotStackedArea({line1, line2, line3})

Use SetStackedAreaOpacity(chartId, opacity) to control the opacity (0–100).

Convenience Plots

These commands bundle common indicator logic with their chart output:

PlotBBandsChart

Plots Bollinger Bands (upper, middle, lower) with automatic band fill.

PlotBBandsChart(1, 'BB', bbands.upper, bbands.middle, bbands.lower)

PlotHistogramSignals

Plots a histogram with optional short/long signal lines — ideal for MACD-style indicators.

PlotHistogramSignals(1, 'MACD', histogram, shortSignal, longSignal)

PlotLineBuySellZone

Plots a line with a coloured buy/sell zone behind it.

PlotLineBuySellZone(1, 'RSI', rsiValue, 30, 70)

Lines & Zones

PlotHorizontalLine

Draws a horizontal line at a specific y-axis value.

PlotHorizontalLine(0, 'Resistance', Red, 50000)

PlotHorizontalZone

Draws a horizontal band between two y-axis values.

PlotHorizontalZone(0, 'Overbought', Red(20), 70, 100)

PlotVerticalLine

Draws a vertical line at a specific timestamp.

PlotVerticalLine(0, 'Event', Orange, 1711800000)

PlotVerticalZone

Draws a vertical band between two timestamps.

PlotVerticalZone(0, 'News Event', Orange(20), 1711800000, 1711886400)

PlotBuySellZone

Draws a horizontal zone with buy (start) and sell (end) line labels.

PlotBuySellZone(0, 30, 70)

Shapes & Markers

PlotShape

Draws a single shape (arrow, cross, diamond, label, etc.) above or below a candle, with optional text.

PlotShape{
    chartId = 0,
    shape = ShapeTriangleUp,
    color = Green,
    size = 3,
    aboveCandle = true,
    text = "Buy",
    textColor = White
}

PlotPivot

Automatically detects and plots pivot highs and lows.

PlotPivot(2, 2)  -- 2 bars left, 2 bars right

MarkCandle

Changes the colour of the last x candles on the chart.

MarkCandle(0, 3)  -- mark the last 3 candles

Axis & Labels

Double Axis

With LineOptions you can snap lines to either axis using LeftAxis or RightAxis. The left and right axis can have independent ranges — perfect for comparing markets with different price levels.

local eth = ClosePrices({market = 'BINANCE_ETH_USDT_'})
Plot(0, 'Binance ETHUSD', eth[1], {side = LeftAxis})

ChartSetAxisOptions

Controls axis visibility, range, and type per side.

ChartSetAxisOptions(0, RightAxis, lows, highs, true, LinearAxis)

ChartAddAxisLabel

Adds a label at a specific y-axis value, with optional fill and text color.

ChartAddAxisLabel(0, RightAxis, "Target", 55000, Green, White)

Color Utilities

ChangeColorOpacity

Converts a hex or RGB color to RGBA with a given opacity (0–100).

local fadedRed = ChangeColorOpacity("#FF0000", 20)  -- returns "rgba(255,0,0,0.2)"