UNPKG

@cmike444/supply-and-demand-zones

Version:

A library for identifying supply and demand zones in candlestick data.

29 lines (28 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isExplosiveCandle = isExplosiveCandle; const constants_1 = require("../constants"); const candleBody_1 = require("./candleBody"); const candleRange_1 = require("./candleRange"); /** * Determines if a given candle is considered "explosive" based on its body-to-range ratio * and, optionally, whether its total range is large enough relative to the local ATR. * * Per spec §2.1: the body must represent >= 70% of the total range, and the total range * must be >= `minATR` (typically 1.5× ATR) to confirm the candle is the Leg-out (ERC). * * @param candle - The candle object containing the data to analyze. * @param threshold - The body/range ratio threshold (default `DEFAULT_EXPLOSIVE_THRESHOLD` = 0.70). * @param minATR - Minimum required total range. When > 0, candles whose range falls below * this value are rejected even if their body ratio qualifies. Pass 0 (default) * to skip the ATR magnitude check. * @returns `true` if the candle qualifies as an ERC, otherwise `false`. */ function isExplosiveCandle(candle, threshold = constants_1.DEFAULT_EXPLOSIVE_THRESHOLD, minATR = 0) { if ((0, candleBody_1.candleBody)(candle) === 0) return false; if (minATR > 0 && (0, candleRange_1.candleRange)(candle) < minATR) return false; return (0, candleBody_1.candleBody)(candle) / (0, candleRange_1.candleRange)(candle) >= threshold; } ;