Panes & scales
Panes decide where an output draws. Price scales decide which axis it is measured against. They are separate choices, and most indicators only need the first.
Both work the same in indicators and definitions.
Panes
There is always one price pane (id: "price") behind the candles. Declare subpanes with pane(...) and send outputs to them with { pane }:
meta({ shortName: "MACD", kind: "overlay" });
const macdPane = pane({ id: "macd", title: "MACD", height: 140 });
output.line({ id: "ema" }); // price pane (the default for an overlay)
output.line({ id: "macd_line", pane: macdPane }); // subpane
output.histogram({ id: "hist", pane: macdPane });Decide which pane each output lands on before writing onBar. An output that leaves out pane falls back to the default, which is how everything ends up on price.
Where outputs land
Setup | Outputs without |
|---|---|
| The price pane |
| The indicator's own subpane |
| The price pane |
| The first declared pane |
Routing applies to every output kind: lines, histograms, markers, output.range, output.hline, output.trendline and layers. pane takes the handle or the pane's id as a string. A zone on a subpane is measured in that pane's values, not in instrument price:
const rsiPane = pane({ id: "rsi", title: "RSI", height: 140 });
output.line({ id: "rsi", pane: rsiPane });
// 70 to 100 in RSI units, not a price band.
output.range({ id: "overbought", pane: rsiPane, color: "rgba(239,83,80,0.12)" });Pane options
Option | Behaviour |
|---|---|
| Required and unique. |
| Label on the subpane |
| Pixels, applied only when the pane is first created. A manual resize wins after that. |
| Lower sorts nearer the price pane; ties keep declaration order |
| Hides the whole pane while a settings condition is false, for example |
| Options for the pane's own right axis. See below. |
visibleWhen is tidier than visibleFrom on every output in the pane. Do not put it on your first declared pane: that one reuses the indicator's main pane, which stays created regardless.
Price scales
Use scale(...) when an output's units differ from the rest of its pane (volume against price), when an oscillator needs fixed bounds, or when a series should fill only part of a pane. Otherwise leave it out.
// Volume along the bottom 20% of the price pane, autoscaled on its own.
const volScale = scale({
id: "vol",
margins: { top: 0.8, bottom: 0 },
priceFormat: { type: "volume" },
});
output.histogram({ id: "vol", scale: volScale });
// An oscillator pinned to 0..100 on its own subpane.
const rsiPane = pane({
id: "rsi",
title: "RSI",
height: 140,
priceScale: { range: { min: 0, max: 100 }, margins: { top: 0.1, bottom: 0.1 } },
});
output.line({ id: "rsi", pane: rsiPane });Scale options
Option | Behaviour |
|---|---|
| Required and unique. |
| The pane the scale belongs to; defaults like an output's |
|
|
|
|
|
|
|
|
| Flips the axis |
|
|
Margins are gaps, not positions. { top: 0.8, bottom: 0 } puts the series in the bottom 20%. A band from 75% to 85% down the pane is { top: 0.75, bottom: 0.15 }.
range and margins need position: "overlay"; on position: "right" the script does not build. On a shared axis a range would only be a floor, because autoscale widens it for every other series on that axis, and margins there would leak into the default every later pane inherits. pane({ priceScale }) is the exception: it configures the pane's own axis, and it accepts both.
Why the surface is narrow
The chart library behind Charts gives each pane exactly two visible axes, left and right. Every other scale is an overlay: autoscaled on its own, with no visible axis, ever. That is why there is no visible option.
Which axes show is decided once for the whole chart, and a pane that disagrees crashes the chart on its next resize. So position: "left" is not offered: which axes the chart shows is a chart setting, not something one indicator changes.
priceFormat is really a series option. Set on a scale, it applies to every series bound to that scale, and the axis labels follow whichever of them draws lowest. Set priceFormat on the output when you need exact control.
Checking the layout
The indicator authoring agent's dry run returns a layout block:
{
"panes": [{ "id": "price", "role": "price" }, { "id": "macd", "title": "MACD" }],
"output_pane": { "ema": "price", "macd_line": "macd", "hist": "macd" },
"emission_count": { "ema": 400, "macd_line": 374, "hist": 374 },
"empty_panes": []
}output_pane already resolves defaults, so an output without pane shows where it really went. A non-empty empty_panes means a pane was declared but no output was sent to it.
After the chart applies the script, the preview's layout block lists what the chart built: allocated should name every declared pane, and unresolved must be empty. An output in unresolved fell back to the price pane: the chart still draws, in the wrong place.
