everget

[RESEARCH] Percentrank Bug

I found a bug with built-in percentrank function. Sometimes it gives unexpected and incorrect results. You can see a one of them on the chart.

ALL scripts which use percentrank function are affected. No matter which version they use, no matter who is their author - ALL scripts which use this built-in function can work incorrectly.

If you want to avoid this bug use _percentrank function (the "shim") - you can find it in the script.

NOTE: Don't push on TradingView Support or Pine Core Team because they already know about this issue and work on the fix. I publish it to warn you.
Usuń z Ulubionych Skryptów Dodaj do Ulubionych Skryptów
A list of Free indicators:
https://bit.ly/2S7EPuN

A list of Paid indicators:
https://bit.ly/33MA81f

Earn $30:
https://www.tradingview.com/gopro/?share_your_love=everget

Toss a coin to your witcher:
PayPal: https://www.paypal.me/alexeverget

Komentarze

Good find. Discrepancies aren't as important on long lengths.
Think ">=" in function should be ">".
+2 Odpowiedz
@LucF, Hi, thank you.
I followed the built-in percentrank() description: "Percent rank is the percents of how many previous values was less than or equal to the current value of given series."
+1 Odpowiedz
LucF everget
@everget, Ah yes. Right. Sry.
+3 Odpowiedz
Found the common bug in both percentile functions (both nearest rank & linear one), at least numpy calculates it a bit different, and I lean towards numpy in terms of accuracy
+1 Odpowiedz
everget gorx1
@gorx1, Could you provide more detail? There is a special Trello board with TradingView staff where script developers report bugs and request new features, so you could participate in it too
Odpowiedz
gorx1 everget
@everget, after further investigation it turned out that numpy calculates percentiles, quantiles etc using some kinda unorthodox methods, for some reason they mess with indexing of elements, while on TradingView the classic methods are being used (checked again, they are implemented right). Now I lean back towards TradingView again xd

More info about how they do it in NumPy:
https://github.com/numpy/numpy/issues/8821#issuecomment-303077978

EDIT:
This is a good article about the different ways how to calculate percentiles
https://analyse-it.com/blog/2013/2/quantiles-percentiles-why-so-many-ways-to-calculate-them
+1 Odpowiedz
FIXED by TradingView
Odpowiedz
Strona główna Skaner akcji Skaner Forex Skaner Krypto Kalendarz ekonomiczny Jak to działa Funkcje wykresów Cennik Poleć przyjaciela Dobre Praktyki Centrum Pomocy Rozwiązania internetowe i brokerskie Widżety Wykresy Lekka Biblioteka Wykresów Blog i wiadomości Twitter
Profil Ustawienia profilu Konto i płatności Poleceni znajomi Monety Wiadomości do działu obsługi Centrum Pomocy Opublikowane Pomysły Obserwujący Obserwujesz Wiadomość prywatna Czat Wyloguj