Charting¶
HaasScript gives you full control over what's drawn on the chart — lines, candlesticks, histograms, shapes, zones, volume bars, and more.
Charting Rules¶
- Charts work with an index. Index 0 is the main plot. A positive index positions below the main plot, a negative index above.
- Index -1 is reserved for the default signal bar — no lines or styling allowed there.
- 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() 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%).
PlotVolume¶
Creates volume bars on a chart index, with separate colors for up/down candles.
PlotSignalBar / PlotSignalEnum¶
Creates a small signal bar chart. PlotSignalEnum takes a signal constant and colors the bar automatically based on the signal.
Line Styles¶
Once you have a line guid from Plot(), you can change its appearance:
PlotCircle¶
Renders the line as circles.
PlotBars¶
Renders the line as bars extending from a base value (default: 0).
PlotHistogram¶
Renders the line as a histogram with separate colors for positive and negative bars.
PlotDoubleColor¶
Changes the line color based on whether the value is above or below a threshold.
PlotShapes¶
Changes the line into a specific shape (cross, diamond, arrow, etc.).
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.
PlotStackedArea¶
Creates a stacked area chart from multiple line guids.
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.
PlotHistogramSignals¶
Plots a histogram with optional short/long signal lines — ideal for MACD-style indicators.
PlotLineBuySellZone¶
Plots a line with a coloured buy/sell zone behind it.
Lines & Zones¶
PlotHorizontalLine¶
Draws a horizontal line at a specific y-axis value.
PlotHorizontalZone¶
Draws a horizontal band between two y-axis values.
PlotVerticalLine¶
Draws a vertical line at a specific timestamp.
PlotVerticalZone¶
Draws a vertical band between two timestamps.
PlotBuySellZone¶
Draws a horizontal zone with buy (start) and sell (end) line labels.
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.
MarkCandle¶
Changes the colour of the last x candles on the chart.
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.
ChartAddAxisLabel¶
Adds a label at a specific y-axis value, with optional fill and text color.
Color Utilities¶
ChangeColorOpacity¶
Converts a hex or RGB color to RGBA with a given opacity (0–100).