anandanand84/technicalindicators

Bullish Hammer calculation is incorrect

ricardonunesdev opened this issue · 4 comments

Hi @anandanand84 and @marcus-n3rd,

I love this module, but it looks like your Bullish Hammer calculation is incorrect.

File: technicalindicators/src/candlestick/BullishHammerStick.ts (link)
Line: 18

isBullishHammer = isBullishHammer && (daysClose - daysOpen) <= 2 * (daysOpen - daysLow);

This means that the body should be twice the size of the wick (body <= 2 * wick).

It should be the other way around.

isBullishHammer = isBullishHammer && (daysClose - daysOpen) * 2 <= (daysOpen - daysLow);

Meaning that the wick should be twice the size of the body (2 * body <= wick).

Right?

Best regards,
Ricardo Nunes

Hi @rlmomin,

I agree with your logic, but now with the code.

Example:
If the body has a size of 10 and the tail has a size of 5, 10 <= 5 x 2 returns true, even though this is clearly not a hammer (body@10 is 2x the tail@5).
The actual formula should be 2 x body <= tail which would return false for the above values 2 x 10 <= 5 but would return true if the body has a size of 5 and the tail a size of 10 (a hammer) 2 x 5 <= 10.

The logic is correct but the code is reversed.

Best regards,
Ricardo Nunes

Created a PR #253 with a fix for this issue.