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

Squeeze Momentum Indicator wrong calculation #3

Open
Andre0711er opened this issue Dec 21, 2024 · 4 comments
Open

Squeeze Momentum Indicator wrong calculation #3

Andre0711er opened this issue Dec 21, 2024 · 4 comments

Comments

@Andre0711er
Copy link

Hi.

I just add the first unit test for Squeeze Momentum Indicator. I just compare calculated values with Tradingview data and they differ.

Following test data are used:
BTCUDST.P from Bybit
1 day interval

might be cool, to check. i don't see the problem yet.
here are the test:
https://github.com/Andre0711er/ta4j-extended/blob/main/src/test/java/org/ta4j/core/indicators/SqueezeMomentumIndicatorTest.java

I know, my changes, on code basis, based on ta4j 0.8-SNAPSHOT yet, but indicator itself aren't touched.

@Cypher01
Copy link
Owner

I checked my implementation and the values are indeed a little bit different than on TradingView, even though the "shape" looks correct, also the zero-line crossings seem to be correct.

Yet I couldn't find a bug in my calculation, but indeed LazyBear's original implementation has a bug. It uses the multiplier for the Keltner Channel for the calculation of the Bollinger Bands.

TradingView PineScript:
dev = multKC * stdev(source, length)
should be
dev = mult * stdev(source, length)

Maybe this is the reason for the differences.

@Andre0711er
Copy link
Author

Question: Did we open up a Ticket for LazyBear. :-) Hehehe, but how?!

@Cypher01
Copy link
Owner

I think so, it would make sense. Afaik there is no issue reporting on TradingView, but there is a comment area below the indicator page.

I just noticed that the bug is known. The indicator was released in July 2014, and the bug was discovered in September 2014. The description starts with:

[--- Updated: Sep 29, 2014 ---]

Fixed a typo in the code where BB multiplier was stuck at 1.5. Thanks @ucsgears for bringing it to my notice.

Updated source: pastebin.com/UCpcX8d7

Use the updated source instead of the what TV shows below.

[---- Original Notes ----]
...

I wonder why the source code in TradingView was not updated, but I assume that this was not possible 10 years ago.

When I have time, I'll copy and paste the fixed code to a private indicator to compare the values. @Andre0711er You can also do this if you want.

I'll keep this issue open until we clarified the situation.

@Andre0711er
Copy link
Author

@Cypher01 Might be a good idea, to add a comment inside the code. including reference to that page. This will help for the next person who to code review or comparing tests between code and tradingview.

Greets,

André.

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