Other timeframes and markets

timeframe("4h", x) and symbol("ETHUSDT", x): a formula on other bars.

For AI tools: this page as Markdown · the whole language in one file

timeframe("4h", x) works x out on the 4h bars of the chart's market; symbol("ETHUSDT", x) on another market's bars, at the chart's timeframe or its own with timeframe = "4h". The names of your script used inside are worked out on those bars too.

A 4h average and the daily close on any chart

1name("Higher timeframe", where = chart)2 3fast = ema(close, 20)4plot(fast, "EMA 20")5plot(timeframe("4h", fast), "EMA 20 on 4h", color = orange, style = steps)6plot(timeframe("1D", close), "Daily close", color = blue, style = steps)

Another market

1name("BTC in ETH")2 3eth = symbol("ETHUSDT", close)4plot(close / eth, "BTC / ETH")
  • Each bar reads the value of the last other bar that had closed by its own close. A 1h bar at 13:00 sees the 4h bar that closed at 12:00, never the one closing at 16:00: history shows what was known then and nothing repaints.
  • The newest bar reads the other bar still forming, so it moves live (on this chart's own market, with every trade).
  • Where the other market has no bar (a closed stock market on a crypto chart) the value is empty: a gap, not an old value.
  • Timeframes: 1m, 2m, 5m, 15m, 30m, 1h, 2h, 4h, 1D, 1W. Up to 4 per script.
  • Not yet: BackQuant data on other bars, or these calls inside your own functions.

See also: timeframe, symbol, Coming from Pine Script