# all files / technicalindicators/lib/candlestick/ HaramiCross.js

100% Statements 16/16
61.54% Branches 8/13
100% Functions 2/2
100% Lines 16/16

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    381×

    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×

    1×

    1×

    1×const CandlestickFinder = require('./CandlestickFinder');

    class HaramiCross extends CandlestickFinder {
        constructor() {
            super();
            this.requiredCount  = 2;
            this.name = 'HaramiCross';
        }
        logic (data) {
            let firstdaysOpen   = data.open[0];
            let firstdaysClose  = data.close[0];
            let firstdaysHigh   = data.high[0];
            let firstdaysLow    = data.low[0]
            let seconddaysOpen  = data.open[1];
            let seconddaysClose = data.close[1];
            let seconddaysHigh  = data.high[1];
            let seconddaysLow   = data.low[1]

            let isHaramiPattern1 = ((firstdaysOpen > seconddaysOpen) &&
                                   (firstdaysClose < seconddaysOpen)&&
                                   (firstdaysClose < seconddaysClose)&&
                                   (firstdaysOpen  > seconddaysLow)&&
                                   (firstdaysHigh  > seconddaysHigh));

            let isHaramiPattern2 = ((firstdaysOpen < seconddaysOpen) &&
                                   (firstdaysClose > seconddaysOpen)&&
                                   (firstdaysClose > seconddaysClose)&&
                                   (firstdaysOpen  < seconddaysLow)&&
                                   (firstdaysHigh  > seconddaysHigh));

            let isSecondDayDoji  = this.approximateEqual(seconddaysOpen, seconddaysClose);

            return ((isHaramiPattern1 || isHaramiPattern2) && isSecondDayDoji);

       }
    }

    module.exports = HaramiCross;