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.
オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードの公開物での再利用には、ハウスルールに準拠する必要があります。お気に入りに登録してチャート上でご利用頂けます。

チャートでこのスクリプトを利用したいですか?
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:
https://www.paypal.me/alexeverget

コメント

Good find. Discrepancies aren't as important on long lengths.
Think ">=" in function should be ">".
+2 返信
@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 返信
LucF everget
@everget, Ah yes. Right. Sry.
+3 返信
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 返信
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
返信
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 返信
FIXED by TradingView
返信
ホーム 株式スクリーナー FXスクリーナー 仮想通貨スクリーナー 経済指標カレンダー アバウト チャート機能 価格 友達紹介 ハウスルール ヘルプセンター ウェブサイト&ブローカー向けソリューション ウィジェット チャートソリューション 軽量チャートライブラリ ブログ&ニュース ツイッター