Documentation Index
Fetch the complete documentation index at: https://docs.darvas.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
ctx is a global object available everywhere in your script. Inside onBar it reflects the current bar being processed. All OHLCV accessors are functions that accept an optional offset argument - the number of bars to look back from the current bar.
Bar metadata
Total number of bars in the current window.
Current timeframe string, e.g.
"1H", "4H", "1D".Current instrument, e.g.
"BTC-USDT-SWAP".Current bar index. 0 = oldest bar in window,
ctx.length - 1 = newest.Alias for
ctx.i().true when processing the most recent (realtime) bar.OHLCV accessors
All accessors accept an optionaloffset - bars back from the current bar. offset = 0 (default) is the current bar; offset = 1 is the previous bar.
Open price.
High price.
Low price.
Close price.
Volume.
Bar open time as unix seconds (UTC).
Composite price accessors
(high + low) / 2(high + low + close) / 3 - typical price, commonly used with ta.cci.(open + high + low + close) / 4Passing accessors as sources
The OHLCV accessors are function references - they match the(offset?) => number | null signature that ta.* functions expect as their source argument:
Example: multi-bar lookback
Related pages
Inputs
input.source returns the same function shape.
Moving averages
ta.* functions that accept a source parameter.
NaN handling
What to do when ctx.close returns null.