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

NameTypeWhat it is
openpriceOpen.
highpriceHigh.
lowpriceLow.
closepriceClose.
volumenumberVolume, or tick count on range, x-ray and renko bars.
timetimeBar time.
indexintBar index.
Example
first_high = intrabar(1m).first().high
strategyindicatoralertlibrarysince 1.0

BarState#

Status of a bar set.

Fields

NameTypeWhat it is
freshboolfalse when this symbol had no bar in the latest interval.
indexintBar index.
confirmedbooltrue once the bar has closed.
Example
gold_fresh = bars(XAUUSD).bar.fresh
strategyindicatoralertlibrarysince 1.0

BarSet#

Bars of a symbol and bar type, aligned to the script.

Fields

NameTypeWhat it is
openpriceOpen.
highpriceHigh.
lowpriceLow.
closepriceClose.
volumenumberVolume, or tick count on range, x-ray and renko bars.
timetimeBar time.
barBarStateBar status.
Example
h4_close = bars(bars: 4h).close
strategyindicatoralertlibrarysince 1.0

Zone#

A price zone, such as an order block or fair value gap.

Fields

NameTypeWhat it is
idstringStable id.
toppriceUpper bound.
bottompriceLower bound.
midpriceMidpoint.
bullishbooltrue for bullish zones.
mitigatedbooltrue once price has traded back into it.
formed_barintBar index where it formed.
formed_timetimeWhen it formed.
touchesintTimes price has returned to it.
statusstringactive, mitigated or broken.
Example
fresh_blocks = order_blocks().filter(z => not z.mitigated)
strategyindicatoralertlibrarysince 1.0

Level#

A support or resistance level.

Fields

NameTypeWhat it is
pricepriceLevel price.
touchesintTouches.
formed_barintBar index where it formed.
strengthnumberRelative strength from 0 to 1.
Example
strong_levels = support_resistance().filter(l => l.touches >= 3)
strategyindicatoralertlibrarysince 1.0

Swing#

A swing point.

Fields

NameTypeWhat it is
pricepriceSwing price.
barintBar index.
timetimeTime.
directionint1 for a swing high, -1 for a swing low.
Example
last_turn = zigzag().last().price
strategyindicatoralertlibrarysince 1.0

Cell#

One heatmap or footprint cell.

Fields

NameTypeWhat it is
barintBar index.
pricepricePrice.
valuenumberValue shown.
Example
hot_cells = liquidity_cells.filter(c => c.value > 0)
strategyindicatoralertlibrarysince 1.0

Trade#

An open or closed trade.

Fields

NameTypeWhat it is
idstringTrade id.
symbolsymbolSymbol.
sidestringlong or short.
sizelotsSize.
entry_pricepriceEntry price.
entry_timetimeEntry time.
exit_pricepriceExit price, once closed.
stoppriceCurrent stop.
targetpriceCurrent target.
rnumberCurrent R multiple.
pnlmoneyProfit or loss.
pnl_pctpercentProfit or loss as a share of balance.
maemoneyMaximum adverse excursion.
mfemoneyMaximum favorable excursion.
bars_openintBars since entry.
tagstringTag.
reasonstringWhy it closed: target, stop, rule, manual or management.
Example
best_r = trades.closed().map(t => t.r).max()
strategyindicatoralertlibrarysince 1.0

Order#

A pending or filled order.

Fields

NameTypeWhat it is
idstringOrder id.
typestringmarket, limit, stop or stop_limit.
sidestringbuy or sell.
symbolsymbolSymbol.
pricepriceOrder price.
sizelotsSize.
expirestimeExpiry time.
tagstringTag.
Example
grid_count = orders.pending(tag: "grid").len
strategyindicatoralertlibrarysince 1.0

Trades#

The strategy's own trades.

Methods

MethodReturnsWhat it does
open(tag, side, market)list<Trade>Open trades.
closed(tag, side, market)list<Trade>Closed trades.
last(tag, side, market)TradeThe most recent trade.
Example
open_longs = trades.open(side: long).len
strategysince 1.0

Orders#

Pending orders on the account.

Methods

MethodReturnsWhat it does
pending(tag, side, market)list<Order>Pending orders.
Example
waiting_count = orders.pending().len
strategyindicatoralertlibrarysince 1.0

HistoryPeriod#

Aggregates of closed trades for a period.

Fields

NameTypeWhat it is
countintClosed trades.
pnlmoneyNet profit or loss.
win_ratepercentShare of winning trades.
profit_factornumberGross profit divided by gross loss.
expectancymoneyAverage result per trade.
max_drawdownmoneyLargest peak-to-trough decline.
avg_rnumberAverage R multiple.
Example
week_pnl = history.this_week.pnl
strategyindicatoralertlibrarysince 1.0

History#

Closed trades on the account.

Fields

NameTypeWhat it is
todayHistoryPeriodToday.
this_weekHistoryPeriodThis week.
this_monthHistoryPeriodThis month.
countintClosed trades.
pnlmoneyNet profit or loss.
win_ratepercentShare of winning trades.
profit_factornumberGross profit divided by gross loss.
expectancymoneyAverage result per trade.
max_drawdownmoneyLargest peak-to-trough decline.
avg_rnumberAverage R multiple.

Methods

MethodReturnsWhat it does
last(period)HistoryPeriodA trailing period.
Example
month_win_rate = history.last(30d).win_rate
strategyindicatoralertlibrarysince 1.0

Session#

A trading session.

Fields

NameTypeWhat it is
namestringSession name.
opentimeOpen time.
closetimeClose time.
timezonestringTime zone.
Example
opens_at = market.session.open
strategyindicatoralertlibrarysince 1.0

LeverageTier#

Leverage for a band of position sizes.

Fields

NameTypeWhat it is
max_sizelotsLargest size in the band.
leveragenumberLeverage.
Example
tier_count = market.leverage_tiers.len
strategyindicatoralertlibrarysince 1.0

Canvas#

The vector canvas passed to on render.

Fields

NameTypeWhat it is
last_barintIndex of the last bar.
visible_fromintFirst visible bar.
visible_tointLast visible bar.
price_minpriceLowest visible price.
price_maxpriceHighest visible price.
widthnumberWidth in pixels.
heightnumberHeight in pixels.

Methods

MethodReturnsWhat it does
path()PathStart a new shape.
text(text, at, align, color, size)voidDraw text.
rect(from, to, fill, border)voidDraw a rectangle.
line(from, to, color, width)voidDraw a line.
Example
on render(canvas):
canvas.text("Hi", at: (canvas.last_bar, close))
strategyindicatorsince 1.0

Path#

A vector shape being drawn.

Methods

MethodReturnsWhat it does
move_to(bar, price)PathMove without drawing.
line_to(bar, price)PathDraw a straight segment.
curve_to(bar, price, control_bar, control_price)PathDraw a curved segment.
close()PathClose the shape.
fill(style)PathFill the shape.
stroke(color, width)PathOutline the shape.
Example
on render(canvas):
shape = canvas.path()
strategyindicatorsince 1.0

color#

Functions available on every color.

Methods

MethodReturnsWhat it does
fade(amount)colorThe same color with transparency.
Example
soft_green = green.fade(80)
strategyindicatoralertlibrarysince 1.0

Try this in the Terminal. AlgoBars is free: $0 a month, no card needed.

Create my free account