NexuScript 1.5
Other timeframes and symbols
Reading a higher timeframe or another symbol, always through the chart's own data.
Runs a block on the bars of a higher timeframe, of this symbol or another, and gives each chart bar the result that applies to it.
Syntax
higher(timeframe::String; symbol::String = "") do
...
end -> block resultDetails
The timeframe is "5", "15", "60", "240", "D", "W", or any number of minutes written as text, and it must be above the chart's. Leave symbol out (or give "") for the chart's own symbol. Both arguments must be fixed. Inside the block, open, high, low, close, volume, time and bar.* are those of the higher bar, history such as close[1] steps through higher bars, and ta calls keep their own memory on the higher bars. symbol.* still describes the chart. The block's last line is its result: a Number, a Bool, or a tuple of them (name the parts to read them as daily.close). The block cannot draw, change or read state variables, or hold another higher. Another symbol is loaded by the chart through its own data, under your own access, so only symbols your chart can show can be read. The chart loads the last 20,000 higher bars. higher keeps memory, so it follows the call-site rule: never inside a for loop or an if whose condition changes from bar to bar. A script may have at most 8 higher call sites.
Missing values
Live and historical bars
A closed chart bar gets the result of the last higher bar that had already closed when the chart bar opened, so history never peeks ahead. The newest chart bar gets the result of the higher bar that is still forming, worked out again on every update, so it can change until that higher bar closes.
Errors
Examples
let daily = higher("D") do
(close = close[1], high = high)
end
plot("Yesterday close", daily.close)let hourly = higher("60") do
ta.ema(close, 20)
end
plot("Hourly EMA 20", hourly, color = color.orange)