Glossary
The words you meet while writing scripts, each explained in a sentence or two, with a link to the page that teaches it.
The words of this guide in one place. Each entry says what the word means here and links to the page that teaches it.
The chart and its data#
- Bar — one candle of the chart: its open, high, low, close and volume over one step of the timeframe. A script runs once for each bar, oldest first. See Lesson 1: Your first script.
- Closed bar — a bar whose time is over; its values no longer change.
- Forming bar — the newest bar, still open: its
closeis the latest price and moves until the bar closes. See Results that look too good. - Series — a value that has one entry for every bar, such as
closeor the result oftech.sma(close, 20). See Values and types. - Timeframe — the length of one bar:
"15"(15 minutes),"60","1D". Atfinput lets the member pick one. See Other timeframes and symbols. - Symbol — the instrument the chart shows. A script reads the chart's own symbol only; data of another symbol is not available in this release.
- Tick — the smallest price step of a symbol,
symbol.tick. Spreads and slippage of a strategy are written in ticks. See Units and literals. - Session — named hours of the day in a time zone, declared with
session name = 08:00 .. 16:30 @ "Europe/London"; its members (.active,.highand the others) follow it. See Trading day and sessions. - Trading day — the day of the symbol's own market, which need not start at midnight.
prior(day)andstate dayfollow it. - Higher timeframe — a timeframe longer than the chart's, read with
data.series. By default it gives the last closed bar of that timeframe.
Writing a script#
- Script — a small program that runs on your chart, kept in My scripts and private to your account. See Write your own scripts.
- Header — the first line,
indicator "Name",strategy "Name"ormodule Name, with its settings indented under it. See Syntax and layout. - Edition — the version of the language a script was written for,
edition = 1in the header. A script keeps its meaning when a later edition exists. - Indicator — a script that draws: lines, levels, marks, backgrounds, tables, labels.
- Strategy — a script that also places simulated orders; the chart marks its trades and shows a results table. See Your first strategy.
- Module — a script whose job is to be imported: it exports functions and types and draws nothing itself. See Modules and libraries.
- Input — a setting the member can change in the settings panel, declared with
input. See Inputs. - Id — the name by which a saved chart finds an input or a plot again; for an input it is the name after
input. See Ids. - Plot — a series drawn on every bar, made with
plot(...). See Plots and drawings. - Level — a horizontal line at a fixed value, made with
level(...). - Shade — the filled space between two plots or two levels, made with
shade(a, b, ...). - Mark — a shape, a character or an arrow on the bars where a condition is true:
mark.shape,mark.char,mark.arrow. - Drawing — a single object placed by bar number and price:
label.new,line.new,box.new,polyline.new, or a table withtable.new. - Pane — the area a script draws in.
display = pricedraws on the price chart; without it the script gets a pane of its own under the chart. - Formatter — the part of the editor that rewrites a script in the one standard layout; the Format button runs it. See The editor.
Values and memory#
- let — a name for a value that is set once on each run and never changes during it. See let, mut and state.
- mut — a value that starts again on each run and may be changed during it.
- state — a value that is set on the first run and kept from one bar to the next.
state daystarts again each trading day. - History —
x[n]is the value ofxn bars back:close[1]is the previous close. - na — "no value": what a series holds before it has enough bars, or where a result does not exist. Test it with
is_na(x);x ?? 0replaces it. See na, errors and arithmetic. - Warm-up — the first bars on which a calculation has no value yet, such as the first 19 bars of a 20-bar average.
- Tuple — several values given back at once, taken apart with
let (a, b) = .... See Functions, types and enums. - Record (type) — your own value with named fields, declared with
type. See Types in shadow mode. - Enum — a closed list of names, declared with
enum; an enum input is a dropdown. - Array — an ordered list, read with
.at(i)from 0. Map — values kept by key. See Values and types. - f-text — a text with values in braces,
f"{close:price}"; after the colon comes the format. See Text and number formatting. - Stateful call — a call that remembers earlier bars, such as
tech.emaordata.series. It keeps one memory for each place it is written (its call site). See Calls that keep a state. - Lazy operator —
and,or,??and the branches ofif ... then ... elserun their right side only when needed, so a stateful call may not stand there (E3302). See Lazy operators.
Messages and limits#
- Diagnostic code — the stable code of a message, such as
E3171. See Diagnostics. - Error — a code that starts with
E: the script does not run until it is fixed. Warning — aW-code: the script runs, but something deserves a look. Hint — anH-code that comes with an error and suggests what to write. - Budget — the amount of work a script may do: 500,000 steps for one bar and 600,000,000 for a whole run. See Limits and budgets.
- Stopped on the chart — what the editor shows when a script that compiled stops while it runs; the engine's message names the bar. See Engine messages.
- Repaint — a signal that appears and disappears while a bar is forming, or that changes after the fact.
- Look-ahead (leak) — a result that used a bar that had not happened yet, for example a higher-timeframe value read before its bar closed. See Results that look too good.
- Determinism — the same script on the same bars gives the same numbers every time. See Determinism and limits.
Strategies#
- Order — a request to open or close a simulated trade:
orders.enter,orders.close,orders.exit. See Strategies and the header. - Order key — the text that names an order, such as
"Long"inorders.enter("Long", side.long); a close or an exit names the same key. - Fill — the moment and price at which a simulated order is carried out. By default a market order placed when a bar closes fills at the next bar's open.
- Position — the trade that is open now:
position.size(positive for a long) andposition.avg_price. - Spread — the gap between the buying and the selling price, set in the
execution:block in ticks. - Slippage — the price moving between an order and its fill, also set in ticks.
- Commission (fees) — what a fill costs, set in the
setup:block, for examplefees = fee.per_lot(3.5). - Drawdown — the fall of the simulated account from a peak; the results table shows the largest one.
- Strategy Lab — the panel that tests a strategy over history and reports its trades and results. See Lesson 15: Testing in the Strategy Lab.
See also: FAQ, Cheat sheet.