Skip to content

API Reference


API Reference / buildCursor

Function: buildCursor() ​

buildCursor(primary, higherTf, higherTfDurationSeconds): number[]

Defined in: src/backtest/cursors.ts:13

For each bar in primary, the index into higherTf of the highest bar that had fully closed by the time that primary bar closed — or -1 before any higher-timeframe bar has closed yet.

A single forward-advancing pointer suffices because both series are sorted ascending by timestamp and higherTf never has more bars than primary over the same span — this is O(primary.length + higherTf.length), not O(primary.length × higherTf.length).

Parameters ​

primary ​

Candle[]

higherTf ​

Candle[]

higherTfDurationSeconds ​

number

Returns ​

number[]

Community project — not affiliated with Dhan. MIT License.