Advanced Features
Multi-timeframe data query handlers, trading session filters, hover collision checks, and custom panel configurations.
Multi-Timeframe Data (ctx.get_timeframe_data)
Requests and matches technical indicator series calculated on higher resolutions (MTF) aligned to the current chart timeframe.
const dailyEma = ctx.get_timeframe_data(syminfo.ticker, '1D', 'ema', 200);
Trading Sessions (ctx.session.in_range)
Validates if a specific unix milliseconds timestamp falls within a target trading session range (e.g. Regular Trading Hours).
const nycSession = ctx.session.in_range(bar.time, "0930-1600:23456");
bgcolor(nycSession ? color.new(color.blue, 90) : na);
Collision & Hover Checks (ctx.is_hovered)
Returns true if the user's cursor currently floats over a bounding rectangle defined around a specific bar index and price level.
if (ctx.is_hovered(bar_index, close, 15, 15)) {
// Render interactive tooltips, highlights, or overlays
}
Indicator Panes (ctx.pane)
Setting this variable to 'new' forces the script indicator to render in an isolated horizontal pane below the main grid (like standard oscillators: RSI, MACD). This is transpiled automatically when utilizing study declarations with overlay=false.
ctx.pane = 'new'; // Oscillates on its own chart pane
Alerts (ctx.alert)
Triggers custom interactive toast alerts and logs conditions during real-time loops. This wrapper is capped internally to execute only once per bar update to prevent duplicate flood.
ctx.alert("Bullish Breakout!", close > resistanceLevel);
Helper Variables & Functions
Pine Script-style helper variables and safety functions natively mapped inside the custom transpiler:
na(val)
Returns true if a value is null, undefined, or NaN.
nz(val, replacement)
Safely returns the value if defined and valid, otherwise returns the replacement (defaults to 0).
hour(time, timezone)
Extracts the hour component (0-23) from a timestamp in a specific timezone context (e.g. 'local' or 'UTC').