Types reference
All 18 types in AlgoBarsX, each with its parameters, defaults, ranges and an example: Bar, BarState, BarSet, Zone, Level, Swing, Cell, Trade, Order, Trades and 8 more.
Bar BarState BarSet Zone Level Swing Cell Trade Order Trades Orders HistoryPeriod History Session LeverageTier Canvas Path color
Bar#
One bar.
Fields
| Name | Type | What it is |
|---|---|---|
open | price | Open. |
high | price | High. |
low | price | Low. |
close | price | Close. |
volume | number | Volume, or tick count on range, x-ray and renko bars. |
time | time | Bar time. |
index | int | Bar index. |
first_high = intrabar(1m).first().highBarState#
Status of a bar set.
Fields
| Name | Type | What it is |
|---|---|---|
fresh | bool | false when this symbol had no bar in the latest interval. |
index | int | Bar index. |
confirmed | bool | true once the bar has closed. |
gold_fresh = bars(XAUUSD).bar.freshBarSet#
Bars of a symbol and bar type, aligned to the script.
Fields
| Name | Type | What it is |
|---|---|---|
open | price | Open. |
high | price | High. |
low | price | Low. |
close | price | Close. |
volume | number | Volume, or tick count on range, x-ray and renko bars. |
time | time | Bar time. |
bar | BarState | Bar status. |
h4_close = bars(bars: 4h).closeZone#
A price zone, such as an order block or fair value gap.
Fields
| Name | Type | What it is |
|---|---|---|
id | string | Stable id. |
top | price | Upper bound. |
bottom | price | Lower bound. |
mid | price | Midpoint. |
bullish | bool | true for bullish zones. |
mitigated | bool | true once price has traded back into it. |
formed_bar | int | Bar index where it formed. |
formed_time | time | When it formed. |
touches | int | Times price has returned to it. |
status | string | active, mitigated or broken. |
fresh_blocks = order_blocks().filter(z => not z.mitigated)Level#
A support or resistance level.
Fields
| Name | Type | What it is |
|---|---|---|
price | price | Level price. |
touches | int | Touches. |
formed_bar | int | Bar index where it formed. |
strength | number | Relative strength from 0 to 1. |
strong_levels = support_resistance().filter(l => l.touches >= 3)Swing#
A swing point.
Fields
| Name | Type | What it is |
|---|---|---|
price | price | Swing price. |
bar | int | Bar index. |
time | time | Time. |
direction | int | 1 for a swing high, -1 for a swing low. |
last_turn = zigzag().last().priceCell#
One heatmap or footprint cell.
Fields
| Name | Type | What it is |
|---|---|---|
bar | int | Bar index. |
price | price | Price. |
value | number | Value shown. |
hot_cells = liquidity_cells.filter(c => c.value > 0)Trade#
An open or closed trade.
Fields
| Name | Type | What it is |
|---|---|---|
id | string | Trade id. |
symbol | symbol | Symbol. |
side | string | long or short. |
size | lots | Size. |
entry_price | price | Entry price. |
entry_time | time | Entry time. |
exit_price | price | Exit price, once closed. |
stop | price | Current stop. |
target | price | Current target. |
r | number | Current R multiple. |
pnl | money | Profit or loss. |
pnl_pct | percent | Profit or loss as a share of balance. |
mae | money | Maximum adverse excursion. |
mfe | money | Maximum favorable excursion. |
bars_open | int | Bars since entry. |
tag | string | Tag. |
reason | string | Why it closed: target, stop, rule, manual or management. |
best_r = trades.closed().map(t => t.r).max()Order#
A pending or filled order.
Fields
| Name | Type | What it is |
|---|---|---|
id | string | Order id. |
type | string | market, limit, stop or stop_limit. |
side | string | buy or sell. |
symbol | symbol | Symbol. |
price | price | Order price. |
size | lots | Size. |
expires | time | Expiry time. |
tag | string | Tag. |
grid_count = orders.pending(tag: "grid").lenTrades#
The strategy's own trades.
Methods
| Method | Returns | What it does |
|---|---|---|
open(tag, side, market) | list<Trade> | Open trades. |
closed(tag, side, market) | list<Trade> | Closed trades. |
last(tag, side, market) | Trade | The most recent trade. |
open_longs = trades.open(side: long).lenOrders#
Pending orders on the account.
Methods
| Method | Returns | What it does |
|---|---|---|
pending(tag, side, market) | list<Order> | Pending orders. |
waiting_count = orders.pending().lenHistoryPeriod#
Aggregates of closed trades for a period.
Fields
| Name | Type | What it is |
|---|---|---|
count | int | Closed trades. |
pnl | money | Net profit or loss. |
win_rate | percent | Share of winning trades. |
profit_factor | number | Gross profit divided by gross loss. |
expectancy | money | Average result per trade. |
max_drawdown | money | Largest peak-to-trough decline. |
avg_r | number | Average R multiple. |
week_pnl = history.this_week.pnlHistory#
Closed trades on the account.
Fields
| Name | Type | What it is |
|---|---|---|
today | HistoryPeriod | Today. |
this_week | HistoryPeriod | This week. |
this_month | HistoryPeriod | This month. |
count | int | Closed trades. |
pnl | money | Net profit or loss. |
win_rate | percent | Share of winning trades. |
profit_factor | number | Gross profit divided by gross loss. |
expectancy | money | Average result per trade. |
max_drawdown | money | Largest peak-to-trough decline. |
avg_r | number | Average R multiple. |
Methods
| Method | Returns | What it does |
|---|---|---|
last(period) | HistoryPeriod | A trailing period. |
month_win_rate = history.last(30d).win_rateSession#
A trading session.
Fields
| Name | Type | What it is |
|---|---|---|
name | string | Session name. |
open | time | Open time. |
close | time | Close time. |
timezone | string | Time zone. |
opens_at = market.session.openLeverageTier#
Leverage for a band of position sizes.
Fields
| Name | Type | What it is |
|---|---|---|
max_size | lots | Largest size in the band. |
leverage | number | Leverage. |
tier_count = market.leverage_tiers.lenCanvas#
The vector canvas passed to on render.
Fields
| Name | Type | What it is |
|---|---|---|
last_bar | int | Index of the last bar. |
visible_from | int | First visible bar. |
visible_to | int | Last visible bar. |
price_min | price | Lowest visible price. |
price_max | price | Highest visible price. |
width | number | Width in pixels. |
height | number | Height in pixels. |
Methods
| Method | Returns | What it does |
|---|---|---|
path() | Path | Start a new shape. |
text(text, at, align, color, size) | void | Draw text. |
rect(from, to, fill, border) | void | Draw a rectangle. |
line(from, to, color, width) | void | Draw a line. |
on render(canvas):canvas.text("Hi", at: (canvas.last_bar, close))Path#
A vector shape being drawn.
Methods
| Method | Returns | What it does |
|---|---|---|
move_to(bar, price) | Path | Move without drawing. |
line_to(bar, price) | Path | Draw a straight segment. |
curve_to(bar, price, control_bar, control_price) | Path | Draw a curved segment. |
close() | Path | Close the shape. |
fill(style) | Path | Fill the shape. |
stroke(color, width) | Path | Outline the shape. |
on render(canvas):shape = canvas.path()color#
Functions available on every color.
Methods
| Method | Returns | What it does |
|---|---|---|
fade(amount) | color | The same color with transparency. |
soft_green = green.fade(80)