anandanand84 / technicalindicators

A javascript technical indicators written in typescript with pattern recognition right in the browser
MIT License
2.14k stars 557 forks source link

Candlestick pattern is giving wrong result for Doji, Bullish Spinning Top, Bearish Spinning Top #186

Open sivaraj-v opened 5 years ago

sivaraj-v commented 5 years ago

Input for the candle

var input = { open: [201], high: [201.25], close: [200.8], low: [200] };

Output for the input: image

Now my question is, candle belongs to which pattern ?
Doji or Bullish Spinning Top or Bearish Spinning Top

image

JKleinne commented 4 years ago

Kinda late, but the way the patterns were coded, in this case it's all three:

let isBearishSpinningTop = bodyLength < upperShadowLength && 
                                 bodyLength < lowerShadowLength;

let isBullishSpinningTop = bodyLength < upperShadowLength && 
                                 bodyLength < lowerShadowLength;

let doji = (isOpenEqualsClose && isHighEqualsOpen == isLowEqualsClose);

In terms of fundamentals, they're quite similar in that they indicate neutrality or indecision, but generally spinning tops' bodies are larger whereas doji's are narrower. Spinning tops always has long legs on either side, indicating a large variance in the high and low.

Logic should have been implemented so that it correctly recognize which of these three fits the mold better.

black-hawk85 commented 3 years ago

If I understood the patterns correctly isBearishSpinningTop shall return true if candle is red and isBullishSpinningTop shall return true if candle is green.

Though I get some cases where both patterns return true.