Skip to content
EliteChart

firstBarAtOrAfter

Documentation


Documentation / @elitechart/core / firstBarAtOrAfter

code
function firstBarAtOrAfter(bars, target): number;

Defined in: compare/compare-types.ts:59

Find the first bar whose time >= target. O(log N) binary search. Returns -1 when every bar is before target.

Parameters

bars

readonly Bar[]

target

TimestampMs

Returns

number

Example

code
import { firstBarAtOrAfter, asTimestampMs } from '@elitechart/core';
const idx = firstBarAtOrAfter(bars, asTimestampMs(Date.now() - 86_400_000));