Other markets, bar sizes and bar types
Higher timeframes, other symbols, Renko, Heikin Ashi and X-Ray bars.
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:00recent_high = intrabar(1m).high.max()barsreads 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.intrabarreads the finer bars inside the current one.close_ofis a shortcut for another symbol's close.- Many functions take
on:to calculate on another set of bars, such asatr(14, on: gold). data.coveragetells a script how much data it actually has, and whether it is exact.
coverage = data.coverage(EURUSD, bars: range(10))enough_history = coverage.exact and coverage.bars >= 5000Several markets in one strategy
strategy "EURUSD and GBPUSD Mean Reversion"markets: EURUSD, GBPUSDbars: 1hmax_open: 2input lookback = 200input entry_z = 2.0input exit_z = 0.5eur = 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.
strategy "Renko Pullback"market: US500bars: renko(5)indicator "X-Ray Flow Bands"bars: xray(20)