Other markets, bar sizes and bar types

Higher timeframes, other symbols, Renko, Heikin Ashi and X-Ray bars.

AlgoBarsX
h4 = bars(bars: higher_tf)
gold = bars(XAUUSD, bars: 15m)
gold_atr = atr(14, on: gold)
cov = data.coverage(EURUSD, bars: range(10))
spread_z = zscore(log(close_of(EURUSD) / close_of(GBPUSD)), 100)
first_hour = time_of_day between 08:00 and 09:00
recent_high = intrabar(1m).high.max()
  • bars reads another bar size, another symbol, or both. A higher bar's value appears only once its candle has closed, so a 5-minute rule cannot peek at a 4-hour bar early.
  • intrabar reads the finer bars inside the current one. close_of is a shortcut for another symbol's close.
  • Many functions take on: to calculate on another set of bars, such as atr(14, on: gold).
  • data.coverage tells a script how much data it actually has, and whether it is exact.
AlgoBarsX
coverage = data.coverage(EURUSD, bars: range(10))
enough_history = coverage.exact and coverage.bars >= 5000

Several markets in one strategy

AlgoBarsX
strategy "EURUSD and GBPUSD Mean Reversion"
markets: EURUSD, GBPUSD
bars: 1h
max_open: 2
input lookback = 200
input entry_z = 2.0
input exit_z = 0.5
eur = bars(EURUSD)
gbp = bars(GBPUSD)
hedge = beta(returns(eur.close), returns(gbp.close), lookback)

Full example: EURUSD and GBPUSD Mean Reversion. Orders take market: to say which symbol they are for.

Other bar types

The header's bars: accepts more than a time: renko, heikin_ashi, range and xray.

AlgoBarsX
strategy "Renko Pullback"
market: US500
bars: renko(5)
AlgoBarsX
indicator "X-Ray Flow Bands"
bars: xray(20)

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

Create my free account