Core reference
The 12 functions and 10 values of the core of the language: signature, effects, phase, cost and tested examples.
The functions every script uses without a prefix: drawing a plot or a level, shading, testing for na and converting a value. The prices of the bar (open, high, low, close, volume) are values of this page.
Functions#
bool#
bool([value])
Converts x to true or false.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
confirmed#
confirmed(value)
The value on a closed bar, and na on the bar that is still forming.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: a number, or na.
falls#
falls(condition)
True on the bar where the condition turns false after being true.
- Effects: keeps a state for each place it is written (a call site) and advances it when execution reaches the call.
- Phase: every bar.
- Cost: one state per call site.
- Returns: true or false.
float#
float([value])
Converts x to a number.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
int#
int([value])
Converts x to a whole number, dropping the fraction.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
is_na#
is_na([value])
True when value is na.
- Effects: none: the result depends on the arguments only.
- Phase: every bar.
- Cost: a fixed number of operations.
- Returns: true or false.
- Examples: Swing pivots, Trend background, Window of the day, Levels from text.
level#
level(price, [name], [color], [style], [width], [display], [key], [was])
Draws a horizontal line at a fixed price.
- Effects: draws on the chart or writes an output.
- Phase: every bar.
- Cost: counts against the limits on drawn objects and outputs.
- Returns: a handle to the level, for
shade. - Examples: RSI zones, RSI written out, Stochastic oscillator, ADX with directional indicators.
plot#
plot(source, [name], [color], [width], [style], [track_price], [base], [offset], [join], [last_bars], [display], [format], [precision], [key], [was])
Draws source on every bar as a line, or in the style you choose.
- Effects: draws on the chart or writes an output.
- Phase: every bar.
- Cost: counts against the limits on drawn objects and outputs.
- Returns: a handle to the plot, for
shade. - Examples: Simple moving average, EMA pair with cross marks, RSI written out, RSI zones.
plot_bars#
plot_bars([open], [high], [low], [close], [name], [color], [last_bars], [display], [format], [precision], [key], [was])
Draws bars from four series.
- Effects: draws on the chart or writes an output.
- Phase: every bar.
- Cost: counts against the limits on drawn objects and outputs.
plot_candles#
plot_candles([open], [high], [low], [close], [name], [color], [wick_color], [last_bars], [border_color], [display], [format], [precision], [key], [was])
Draws candles from four series.
- Effects: draws on the chart or writes an output.
- Phase: every bar.
- Cost: counts against the limits on drawn objects and outputs.
rises#
rises(condition)
True on the bar where the condition turns true after being false.
- Effects: keeps a state for each place it is written (a call site) and advances it when execution reaches the call.
- Phase: every bar.
- Cost: one state per call site.
- Returns: true or false.
shade#
shade(a, b, [color], [name], [last_bars], [fill_gaps], [display], [max], [min], [max_color], [min_color], [key], [was])
Colours the space between two plots or levels.
- Effects: draws on the chart or writes an output.
- Phase: every bar.
- Cost: counts against the limits on drawn objects and outputs.
- Examples: RSI zones, Bollinger bands.
Values#
close— The close of the bar.high— The high of the bar.hl2— (high + low) / 2hlc3— (high + low + close) / 3hlcc4— (high + low + close + close) / 4low— The low of the bar.ohlc4— (open + high + low + close) / 4open— The open of the bar.trading_dayvolume— The volume of the bar.