> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hyperprop.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Plots and drawings

> Draw lines, histograms, boxes, labels, markers and background bands from your indicator.

Everything a script draws comes from the object `compute` returns. `plots` is
required (it may be empty); every other key is optional.

## Plots

A plot is one value per chart bar. Use `null` where there is no value.

```js theme={null}
plots: [{
  title?,         // legend name
  values,         // Array<number | null>, one per bar
  color?,         // hex or rgba()
  width?,         // line width in px
  style?,         // 'line' (default) | 'dashed' | 'dotted' | 'histogram'
  negativeColor?, // histogram bars below zero
}]
```

```js theme={null}
function compute(bars, inputs, hp) {
  const closes = bars.map(b => b.c);
  const fast = hp.ema(closes, 12), slow = hp.ema(closes, 26);
  const diff = fast.map((v, i) => v == null || slow[i] == null ? null : v - slow[i]);
  return {
    plots: [
      { title: 'MACD', values: diff, style: 'histogram', color: '#26a69a', negativeColor: '#ef5350' },
      { title: 'Signal', values: hp.ema(diff, 9), color: '#f59e0b', style: 'dashed' },
    ],
    guides: [0],
  };
}
```

## Pane options

| Key | Effect |
| - | - |
| `range: { min, max }` | Fixes the value scale of a separate pane, for example `0` to `100` for an oscillator. |
| `guides: number[]` | Dashed horizontal reference levels. |
| `decimals: number` | Precision for the axis and legend values. |

## Coordinates

Drawings use **bar indices** for x: `0` is the first bar in `bars` and
`bars.length - 1` is the latest. Fractional values and indices past the last
bar are allowed, so zones and rays can extend into the future. Y is a price in
an overlay pane, or the script's own value in a separate pane.

Boxes and background bands render **under** the price series. Lines, markers
and labels render **on top**. Everything is clipped to the pane.

## Boxes

```js theme={null}
boxes: [{ x1, y1, x2, y2, bg?, border?, borderWidth?, text?, textColor? }]
```

Use `rgba()` colors for translucent zone fills.

## Labels

```js theme={null}
labels: [{ x, y, text, color?, textColor?, anchor?, size? }]
// anchor: 'up' (bubble above the point) | 'down' | 'left' | 'right' | 'center'
```

## Lines

```js theme={null}
lines: [{ x1, y1, x2, y2, color?, width?, style? }]
// style: 'solid' (default) | 'dashed' | 'dotted'
```

## Markers

```js theme={null}
markers: [{ x, y, shape?, color?, text?, textColor? }]
// y: a number, or 'above' / 'below' to anchor to the bar's high / low
// shape: 'triangle-up' | 'triangle-down' | 'circle' | 'square' | 'arrow-up' | 'arrow-down'
```

## Background bands

```js theme={null}
bg: [{ x1, x2, color }]   // a vertical band across the full pane height
```

## Example: previous-bar breakout markers

```js theme={null}
function compute(bars) {
  const markers = [];
  for (let i = 1; i < bars.length; i += 1) {
    if (bars[i].c > bars[i - 1].h) markers.push({ x: i, y: 'below', shape: 'triangle-up', color: '#26a69a' });
    if (bars[i].c < bars[i - 1].l) markers.push({ x: i, y: 'above', shape: 'triangle-down', color: '#ef5350' });
  }
  return { plots: [], markers: markers.slice(-500) };
}
```

## Caps

Boxes render in the order you return them, up to **2000** boxes that fall in
the visible range. Boxes outside the visible range don't count, and older
zones that extend into view still render. Labels, lines, markers and
background bands use the first **2000** items of each type. Keep your output
bounded, for example by only emitting recent history. See [Limits](https://docs.hyperprop.com/indicators/limits.md).


## Related topics

- [Porting from Pine Script](https://docs.hyperprop.com/indicators/pine-porting.md)
- [Changelog](https://docs.hyperprop.com/changelog.md)
- [Limits](https://docs.hyperprop.com/indicators/limits.md)
- [Continuous futures](https://docs.hyperprop.com/guides/continuous-futures.md)
- [Other timeframes](https://docs.hyperprop.com/indicators/other-timeframes.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.