From e1ec6653ea975245a995ffee7bff43ad95430797 Mon Sep 17 00:00:00 2001 From: NguyenNguyen Date: Wed, 28 Jun 2023 16:20:06 +0700 Subject: [PATCH] Update doji.js --- candlestick-pattern/doji.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/candlestick-pattern/doji.js b/candlestick-pattern/doji.js index 5b88594..9aa6f2a 100644 --- a/candlestick-pattern/doji.js +++ b/candlestick-pattern/doji.js @@ -4,9 +4,9 @@ const THRESHOLD = parseFloat(2 / 10_000) const isDojiPattern = async (input) => { try { - const last = input.close.length - 1 - const body = Math.abs(input.close[last -1] - input.open[last - 1]) - if (parseFloat(body / input.close.slice(-1)) < THRESHOLD) { + const last = input.open.length - 2 // confirmed candle : last - 2 + const body = Math.abs(input.close[last] - input.open[last]) + if (parseFloat(body / input.close[last]) < THRESHOLD) { return true } return false