Skip to content

Documentation / @finchart/indicators / AnchorPredicate

Type Alias: AnchorPredicate ​

AnchorPredicate = (point, index, previous) => boolean

Defined in: indicators/src/factories.ts:930

Where a new period opens. Given a bar, its index, and the bar before it — null where there is nothing behind, which is what vwap passes at index 0. pivotPoints opens its first period without asking at all, so a predicate written for it is never called with null.

The third argument is what makes a session boundary answerable: "did a new one open here" is a comparison between two bars, not a property of one, and without it every consumer closed over the array to index it again. periodAnchor turns any rule about where a bar starts into one of these, so a venue's own calendar needs the rule and nothing else.

A predicate may declare fewer parameters than it is given — one or two is ordinary TypeScript and nothing about that changed. What changed is what an indicator passes: code that reads this type back out and calls it with two arguments, or assigns it to a two-parameter type, has to name the third now.

Parameters ​

point ​

OHLC

index ​

number

previous ​

OHLC | null

Returns ​

boolean