pricehistory
Version:
Transforms raw OHLCV series data into enriched candles with technical indicators, pattern recognition, and trend analysis.
33 lines • 1.24 kB
JavaScript
import * as utilN from "@nameer/utils";
function setCandlePhase(opt, candle) {
if (opt.phase === false)
return;
const high = candle[`signalSma${opt.phase}PriceCloseToPriceHigh`];
const low = candle[`signalSma${opt.phase}PriceCloseToPriceLow`];
const green = candle[`sma${opt.phase}ColorGreen`];
const red = candle[`sma${opt.phase}ColorRed`];
if (high === undefined ||
low === undefined ||
green === undefined ||
red === undefined)
return;
const phaseDistribution = utilN.math.num(high * (green / 10));
const phaseAccumulation = utilN.math.num(-low * (red / 10));
if (phaseDistribution === undefined || phaseAccumulation === undefined) {
return;
}
if (phaseDistribution > phaseAccumulation) {
candle.phaseDistribution = phaseDistribution;
candle.phaseAccumulation = 0;
}
else if (phaseAccumulation > phaseDistribution) {
candle.phaseDistribution = 0;
candle.phaseAccumulation = phaseAccumulation;
}
else {
candle.phaseDistribution = phaseDistribution;
candle.phaseAccumulation = phaseAccumulation;
}
}
export default setCandlePhase;
//# sourceMappingURL=candle.setPhase.js.map