QuantNomad

Hurst Exponent

My first try to implement Full Hurst Exponent .

The Hurst exponent is used as a measure of long-term memory of time series. It relates to the autocorrelations of the time series and the rate at which these decrease as the lag between pairs of values increases

The Hurst exponent is referred to as the "index of dependence" or "index of long-range dependence". It quantifies the relative tendency of a time series either to regress strongly to the mean or to cluster in a direction.

In short, depending on the value you can spot the trending / reversing market.
  • Values 0.5 to 1 - market trending
  • Values 0 to 0.5 - market tend to mean revert

Hurst Exponent is computed using Rescaled range (R/S) analysis.
I split the lookback period (N) in the number of shorter samples (for ex. N/2, N/4, N/8, etc.). Then I calculate rescaled range for each sample size.
The Hurst exponent is estimated by fitting the power law. Basically finding the slope of log(samples_size) to log( RS ).

You can choose lookback and sample sizes yourself. Max 8 possible at the moment, if you want to use less use 0 in inputs.

It's pretty computational intensive, so I added an input so you can limit from what date you want it to be calculated. If you hit the time limit in PineScript - limit the history you're using for calculations.


####################

Disclaimer
Please remember that past performance may not be indicative of future results.
Due to various factors, including changing market conditions, the strategy may no longer perform as good as in historical backtesting.
This post and the script don’t provide any financial advice.
Script de código aberto

No verdadeiro espírito TradingView, o autor deste script o publicou com código aberto, para que os traders possam compreendê-lo e verificá-lo. Um brinde ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para utilizá-lo em um gráfico.

Quer usar esse script no gráfico?
Courses:
PineScript Programming: https://qntly.com/pinepro
TradingView Essential: https://qntly.com/tve

Access to Pro Indic.: https://qntly.com/proind

YouTube: https://qntly.com/youtube
Discord: https://qntly.com/discord
Telegram: https://qntly.com/tel

Comentários

500 moedas
Resposta
Nice try, very good script. I made a rescaled range HE before the array function was implemented on tv. Was going to update my code and publish it but didn't have the time. Now your script does the job with more efficient code. Good job.
Some small suggestions:
Regression slope is best when there are ten or more points on log-log plot.
For rescaled range HE, you can't really tell if there's significant autocorrelation by just looking at if it's above or below 0.5. There's an expected value for rescaled range HE, for 1024 lookback you used, it should be around 0.54. Then you can calculate the standard error of the regression and divide it by the absolute value of HE - 0.54 (expected value) to get the Z score. Or you can just compute a confidence interval around the expected value.
+5 Resposta
QuantNomad balipour
@balipour, Thanks for your input.
I probably have to optimize code bit more for 10 > points. It can easily hit 200ms bar limit with it.
I'll continue working on it. Confidence interval can be a really nice addition. Will keep you posted with future updates.
+2 Resposta
Is there any possibility to make a video about its usage?
+1 Resposta
QuantNomad oneanalyst
@oneanalyst, I'll try to create a video about it at some point
+1 Resposta
How to use this? pls do include some guidance instruction
Resposta
This publication is now featured in our Editors' Picks: https://www.tradingview.com/scripts/editors-picks/ .
In the name of all TradingViewers, thank you for your valuable contribution to the community, and congrats!
Resposta
lookin good homie!
Resposta
Início Rastreador de Fundamentos Rastreador Forex Rastreador de Criptomoedas Calendário Econômico Sobre Recursos gráficos Preços Indique um Amigo Regras da Casa Central de Ajuda Soluções para Sites & Corretoras Widgets Soluções em Gráficos Biblioteca de Gráficos Lightweight Blog & Notícias Twitter
Perfil Configurações de perfil Conta e Cobrança Amigos indicados Moedas Meus Tíquetes de Suporte Central de Ajuda Mensagens Privadas Conversa Deslogar