UNPKG

pricehistory

Version:

Transforms raw OHLCV series data into enriched candles with technical indicators, pattern recognition, and trend analysis.

39 lines 1.87 kB
import * as utilN from "@nameer/utils"; function setCandlePressure(opt, candle) { if (opt.pressure === false) return; const priceRange = candle.priceRange ?? utilN.math.change.num(candle.priceLow, candle.priceHigh); const priceRangeDiff = candle.priceRangeDiff ?? utilN.math.change.percent(candle.priceLow, candle.priceHigh); if (priceRange === undefined || priceRangeDiff === undefined) return; const candlestickUpper = candle.candlestickUpper ?? (candle.priceHigh !== undefined && candle.priceOpen !== undefined && candle.priceClose !== undefined ? utilN.math.percent(candle.priceHigh - Math.max(candle.priceOpen, candle.priceClose), priceRange) : undefined); const candlestickLower = candle.candlestickLower ?? (candle.priceLow !== undefined && candle.priceOpen !== undefined && candle.priceClose !== undefined ? utilN.math.percent(Math.min(candle.priceOpen, candle.priceClose) - candle.priceLow, priceRange) : undefined); if (candlestickUpper === undefined || candlestickLower === undefined) return; const high = candle[`signalSma${opt.pressure}PriceCloseToPriceHigh`]; const low = candle[`signalSma${opt.pressure}PriceCloseToPriceLow`]; const green = candle[`sma${opt.pressure}ColorGreen`]; const red = candle[`sma${opt.pressure}ColorRed`]; if (high === undefined || low === undefined || green === undefined || red === undefined) { return; } candle.pressureSelling = utilN.math.num(priceRangeDiff * (candlestickUpper / 100) * high * green); candle.pressureBuying = utilN.math.num(priceRangeDiff * (candlestickLower / 100) * -low * red); } export default setCandlePressure; //# sourceMappingURL=candle.setPressure.js.map