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.
Mã nguồn mở

Với tinh thần của TradingView, tác giả đã xuất bản tập lệnh theo mã nguồn mở, vì thế trader có thể dễ dàng hiểu và tùy chỉnh được. Bạn có thể sử dụng miễn phí, hoặc tùy chỉnh lại mã đã được cấp phép bởi Quy tắc Chung. Bạn có thể sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
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

Bình luận

500 xu
Phản hồi
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 Phản hồi
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 Phản hồi
Is there any possibility to make a video about its usage?
+1 Phản hồi
QuantNomad oneanalyst
@oneanalyst, I'll try to create a video about it at some point
+1 Phản hồi
How to use this? pls do include some guidance instruction
Phản hồi
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!
Phản hồi
lookin good homie!
Phản hồi
Trang chủ Bộ lọc cổ phiếu Bộ lọc Forex Bộ lọc Tiền điện tử Lịch kinh tế Giới thiệu Tính năng Biểu đồ Trả phí Giới thiệu bạn Quy tắc Áp dụng Trung tâm Trợ giúp Giải pháp cho Website & Nhà môi giới Widget Giải pháp biểu đồ Thư viện Biểu đồ Lightweight Blog & Tin tức Twitter
Hồ sơ Tùy chỉnh Hồ sơ Tài khoản và Thanh toán Giới thiệu bạn Xu Ticket Hỗ trợ của tôi Trung tâm Trợ giúp Tin nhắn riêng Trò chuyện Đăng xuất