Appearance
Shape
Kind: module
Namespace: shape
Plots a symbol at a price level for each bar, handy for signals, highlights, and short labels. Use style, location, color, and optional text to control how it looks (Styles, Location).
Each shape series maintains one value per bar. A new value is added when a new bar starts and replaced when the current bar updates.
shape()
Kind: func
Plots one symbol at the given value for each active shape call.
Syntax
shape(value) → void
shape(value, {title, style, offset, location, overlay, color, textColor, text}) → voidArguments
| Name | Type | Description |
|---|---|---|
| value | number, series | Value or series to plot |
Options
Static (captured on the first call, ignored afterwards):
| Name | Type | Default | Description |
|---|---|---|---|
| title? | string | null | Display name in the legend |
| style? | const | shape.STYLE_XCROSS | Visual style (see Styles) |
| offset? | int | 0 | Horizontal offset in bars (positive = right) |
| location? | location | location.ABOVE_BAR | Vertical placement (e.g. location.ABOVE_BAR, location.BELOW_BAR) |
| overlay? | boolean | true | Draw on the main price chart (true) or in a separate pane (false) |
Dynamic (can change per bar):
| Name | Type | Default | Description |
|---|---|---|---|
| color? | color | null | Shape color |
| textColor? | color | null | Text label color (independent of the shape color) |
| text? | string | "" | Text label. Passing null or omitting is the same as "" (no text) |
Returns
void
Caveats
- Must be called inside
onTick(), not in theinitsection - Must be at the top level of
onTick(), not inside conditionals or loops. This ensures the call count and order remain constant across ticks
Pitfall
javascript
function onTick() {
if (bar.isConfirmed()) {
shape(close); // ❌ inside conditional
}
}Example
javascript
const length = input.double("length", 20);
function onTick() {
const sma = ta.sma(close, length);
shape(close > sma ? high : NaN, {
title: "Above SMA",
style: shape.STYLE_ARROW_UP,
location: location.ABOVE_BAR,
color: color.LIME,
});
}Styles
Visual style constants for shape() output. Use with the style option.
shape.STYLE_TAG
Kind: constant
Value: TAG
Tag shape at the data point.
shape.STYLE_ARROW_UP
Kind: constant
Value: ARROW_UP
Upward arrow at the data point.
shape.STYLE_ARROW_DOWN
Kind: constant
Value: ARROW_DOWN
Downward arrow at the data point.
shape.STYLE_XCROSS
Kind: constant
Value: XCROSS
Diagonal cross (X) at the data point.
shape.STYLE_CROSS
Kind: constant
Value: CROSS
Plus cross (+) at the data point.
shape.STYLE_BEACON
Kind: constant
Value: BEACON
Beacon (diamond-style) marker at the data point.
shape.STYLE_CIRCLE
Kind: constant
Value: CIRCLE
Circle at the data point.
See location for the full list of vertical placement constants. Common choices for shape() are location.ABOVE_BAR and location.BELOW_BAR.