@thuantan2060/technicalindicators
Version:
Techincal Indicators written in javascript
68 lines (61 loc) • 3.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DEFAULT_BULLISH_HARAMI_CONFIG = void 0;
exports.bullishharami = bullishharami;
exports.default = void 0;
var _CandlestickFinder = _interopRequireWildcard(require("./CandlestickFinder"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/**
* Configuration interface for BullishHarami pattern.
* Only requires scale parameter since this pattern uses direct price comparisons.
*/
/**
* Default configuration for BullishHarami pattern.
*/
const DEFAULT_BULLISH_HARAMI_CONFIG = exports.DEFAULT_BULLISH_HARAMI_CONFIG = {
..._CandlestickFinder.DEFAULT_CANDLESTICK_CONFIG
};
class BullishHarami extends _CandlestickFinder.default {
constructor(config) {
const finalConfig = {
...DEFAULT_BULLISH_HARAMI_CONFIG,
...config
};
super(finalConfig);
this.requiredCount = 2;
this.name = "BullishHarami";
}
logic(data) {
// Previous day (older) - index 0
let prevOpen = data.open[0];
let prevClose = data.close[0];
let prevHigh = data.high[0];
let prevLow = data.low[0];
// Current day (most recent) - index 1
let currOpen = data.open[1];
let currClose = data.close[1];
let currHigh = data.high[1];
let currLow = data.low[1];
// Validate OHLC data
if (!this.validateOHLC(prevOpen, prevHigh, prevLow, prevClose) || !this.validateOHLC(currOpen, currHigh, currLow, currClose)) {
return false;
}
// Previous day should be bearish (large red candle)
let isPrevBearish = prevClose < prevOpen;
// Current day should be bullish or near-doji (small green candle or very small body)
// Note: approximateEqual uses scale for price comparison precision
let isCurrBullish = currClose > currOpen || this.approximateEqual(currOpen, currClose);
// Current day should be completely contained within previous day's body and range
// (Harami means "inside" in Japanese)
let isInsidePrevBody = currOpen < prevOpen && currOpen > prevClose && currClose < prevOpen && currClose > prevClose;
let isInsidePrevRange = currHigh <= prevHigh && currLow >= prevLow;
return isPrevBearish && isCurrBullish && isInsidePrevBody && isInsidePrevRange;
}
}
exports.default = BullishHarami;
function bullishharami(data, config = DEFAULT_BULLISH_HARAMI_CONFIG) {
return new BullishHarami(config).hasPattern(data);
}
//# sourceMappingURL=BullishHarami.js.map