Skip to main content
Call once, first.

indicator()

Names the script and says where it draws. Must be the first statement.

IndicatorOptions

boolean
Draw on the price pane (true) or in the script’s own pane below it (false, the default).
string
A short name for the legend.
number
Decimal places for values; defaults to the market’s price precision on the price pane.
'percent'
'percent': values in the script’s own pane (axis, tags, legend) print with a % sign. Set the values in percent.
boolean
false keeps every input’s value out of the script’s name in the legend (“Bands” rather than “Bands 20 2”). Default true. An input’s own legend: false keeps one out.
'price' | 'own'
'own': the plots on the price pane share a hidden scale of their own, drawn over the candles without moving the price scale, as Pine’s scale.none. Default 'price'.
number
Caps on drawing objects, oldest removed first. Default 50 each, at most 500.
number
number
number
number
true | { market?: string; interval?: IntervalCode }
A panel script: it runs in a script panel of its own rather than on a chart, on the market and interval named here, or the panel’s choice where they are left out. bars() is that market’s bars, which clock the script; its panel blocks and graphs fill the panel. Plots are not drawn. A market-wide read (20 markets’ positioning, a cross-market table) is a panel script.

strategy

A strategy: an indicator whose target position the engine trades, charging what the venue would have (fees, slippage from the order book, funding), with an equity curve, fills on the chart and a Strategy report. Must be the first statement, in place of indicator().
void
(fraction: number): void
The position wanted from this bar’s close, as a fraction of equity: 1 fully long, −1 fully short, 0 flat, held to the leverage. Applies on closed bars only. The same value again holds the position as it is; a new value trades to it.
(fraction: number, order: RestingOrderOptions): void
The same position wanted once price reaches a stop or a limit, resting until then.
(fraction: number, options: { market: string }): void
A portfolio’s weight wanted in one market from this bar’s close, as a fraction of equity, filled at that market’s next daily open. Markets not set keep what they hold. The book is held to leverage at the fill: the markets traded give way, those left alone do not.
(usd: number, order?: RestingOrderOptions): void
The position wanted as a notional in USD: positive long, negative short. One market only.
(coins: number, order?: RestingOrderOptions): void
The position wanted in coins: positive long, negative short, held to the leverage. One market only.
(options: ExitOptions): void
Close the position when price reaches a stop or a limit, whichever it reaches first; the other is then cancelled. It rests until it fills or the position it closes is closed. One market only.
(id?: string): void
Cancel the resting order or exit with this id, or every one.
(weights: Readonly<Record<string, number>>): void
A portfolio’s whole book from this bar’s close, market to weight: a market left out goes to 0.
StrategyPosition
The chart’s market’s position; in a portfolio, its sleeve.
readonly PortfolioPosition[]
A portfolio’s open positions, largest first.
number
Cash plus the open position marked at the last price.
number
number
Round trips closed so far: a position opened and closed, or flipped. One market only.
{ readonly fees: number; readonly slippage: number; readonly funding: number }
What trading has cost so far, in USD: funding positive when received.

StrategyOptions

A strategy’s display options are an indicator’s (overlay: true draws its plots over the candles); it runs on a chart, never in a panel.
number
Starting equity in USD. Default 10,000.
string | number
Load history back to this date before the run, such as '2025-03-01'; by default what the chart holds.
'nextOpen' | 'close'
'nextOpen' (the default): a target set on a bar’s close fills at the next bar’s open, so a script never trades on a close it hasn’t seen. 'close': at the signal bar’s own close.
'venue' | { takerBps: number; makerBps?: number }
'venue' (the default): the venue’s base tier, a market or stop fill paying the taker rate and a limit fill the maker rate. Or rates of your own; makerBps defaults to takerBps.
'book' | { bps: number }
'book' (the default): what a market order of the fill’s size paid against the archived book at the signal bar’s close (Hyperliquid and HIP-3), fallbackBps where it has no reading. Or a flat cost.
number
The cost where the book has no reading, in basis points. Default 2.
boolean
Charge funding while a position is open, every hour as the venue settles it. Default true; time charts of 1m and up only.
number
The most a target may ask for, as a multiple of equity. Default 1. Above 1 a position can be liquidated.
true | { history?: number }
A portfolio: one account, shared cash and cross margin, across every Hyperliquid perp, set with strategy.target(weight, { market }) or strategy.targets({...}). It runs on any time chart from 1m to 1W: each market fills at the open of its own next bar at the chart’s interval, is marked at its closes and liquidated at its bars’ worst prices, from the same bars its chart shows (on 1D every market’s from the universe history’s months, which hold exactly those bars; intraday each market’s own stream). The chart shows its own market’s fills and the whole account’s equity. Funding is charged every hour at the day’s mean hourly rate. history is how many days of the universe history (for picking markets) load before the chart’s first bar (default 180). Slippage is a flat cost (slippage: { bps }, default fallbackBps, 2): the archive’s book readings start on 2026-09-06.

PortfolioPosition

One market of a portfolio’s book.
string
number
Notional over equity, signed: 0.2 is a fifth of equity long.

StrategyPosition

number
Coins held: positive long, negative short.
'long' | 'short' | 'flat'
number
The average entry; na when flat.
number
number
number
Fills that opened or added to the position since it was last flat; 0 when flat. A portfolio’s open sleeve counts one.
number
The chart bar (chart.index) and the time of the fill that opened the position; na when flat, and in a portfolio.
Time

RestingOrderOptions

A resting order: it waits until price reaches it rather than filling at the next open. A stop fills when price trades through it, at its price (or the open, when a bar opens past it), as a taker; a limit fills when price trades at it, at its price or a better open, as a maker with no slippage. An order placed on a bar’s close can fill from the next bar on, and stays until it fills, is replaced by another with its id, or is cancelled.
number
Fill once price trades at or through this price: above for a buy, below for a sell.
number
Fill once price trades at this price or better: below for a buy, above for a sell.
string
Names the order: another with this id replaces it, strategy.cancel(id) removes it. Default 'entry'. A target with an id and no price is a market target that cancels the resting one.

ExitOptions

number
Close the position when price trades through this price.
number
Close the position when price trades at this price.
number
A stop this far from the entry price, in price units, placed once the position is open.
number
A limit this far from the entry price, in price units, placed once the position is open.
'long' | 'short'
Close only a long or only a short. Default: the position open now, or else the next one opened.
string
Another exit with this id replaces it. Default 'exit'.

Next step

Continue with Inputs.
Last modified on November 2, 2026