Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bullish Hammer calculation is incorrect #250

Open
ricardonunesdev opened this issue Jan 14, 2022 · 4 comments
Open

Bullish Hammer calculation is incorrect #250

ricardonunesdev opened this issue Jan 14, 2022 · 4 comments

Comments

@ricardonunesdev
Copy link

ricardonunesdev commented Jan 14, 2022

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

@rlmomin
Copy link

rlmomin commented Jan 14, 2022 via email

@ricardonunesdev
Copy link
Author

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

@rlmomin
Copy link

rlmomin commented Jan 14, 2022 via email

ricardonunesdev added a commit to ricardonunesdev/technicalindicators that referenced this issue Jan 20, 2022
@ricardonunesdev
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants