Skip to content
EliteChart

crossDirection

Documentation


Documentation / @elitechart/core / crossDirection

code
function crossDirection(
   prevBar, 
   bar, 
   threshold): "up" | "down" | "touch" | "miss";

Defined in: alerts/alert-types.ts:59

Classify crossing direction on a single bar. 'up' if previous bar closed below the threshold and current bar's high crossed it; 'down' for the inverse. 'touch' when the threshold is within the bar but the prior close doesn't establish a direction. 'miss' otherwise.

Parameters

prevBar

Bar | undefined

bar

Bar

threshold

number

Returns

"up" | "down" | "touch" | "miss"

Example

code
import { crossDirection } from '@elitechart/core';
const dir = crossDirection(prevBar, bar, 67_500);
if (dir === 'up') notify('Crossed up at 67500');