mortdiggiddy

Spearman Rank Correlation Coefficient

mortdiggiddy Telah dikemas kini   
I'm pleased to introduce this script in honor of the new array functions introduced to PineScript version 4.0. This update is a long time coming and opens the door to amazing scripting possibilities!

Definition

Named after Charles Spearman and denoted by the Greek letter ‘ρ’ (rho), the Spearman rank correlation coefficient is the nonparametric version of the Pearson correlation coefficient. Use the Spearman rank correlation when you have two ranked variables, and you want to see whether the two variables covary. That is, as one variable increases/decreases, the other variable tends to increase/decrease respectively.

It is best used to discover if two variables (and in this first version of the indicator, two ticker symbols) increase and decrease together. There are advantages to using this version of correlation vs. the Pearson R.

Interpretation

The value oscillates between +1 and -1.

  • A value of +1 means the two variables are perfectly correlated, that is they are increasing and decreasing together in perfect harmony.
  • A value of -1 means the two variables exhibit a perfect negative correlation, that is they increase and decrease oppositely.
  • A value of zero means the two variables are not correlated at all (noise).
Nota Keluaran:
  • Removed the 'lookahead = true' parameter from the security function, not needed.
  • Fixed logic of duplicates to be more straightforward.
Nota Keluaran:
  • Fixed issue with hLines.
Nota Keluaran:
  • Updated symbol input to input.symbol.
Nota Keluaran:
  • Fixed -1 index out of bounds exception.
Nota Keluaran:
  • Removed index out of bound corner cases.
Nota Keluaran:
  • Added primary source option. The source input that is correlated to the selected symbol's closing price. By default the close of the chart's symbol is correlated against the close of the selected symbol below, however an alternate source can be used to correlated against the selected symbol, such as an indicator on the chart.

Skrip sumber terbuka

Dalam semangat TradingView yang sebenar, penulis skrip ini telah menerbitkannya dengan menggunakan sumber terbuka supaya pedagang-pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda dapat menggunakannya secara percuma tetapi penggunaan semula kod ini dalam penerbitan adalah dikawalselia oleh Peraturan Dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Ingin menggunakan skrip ini pada carta?