Login Page - Create Account

Support Board


Date/Time: Fri, 07 Feb 2025 23:02:30 +0000



Post From: New Study - Rescaled Range - Hurst Exponent

[2017-03-21 20:02:54]
User71961 - Posts: 144
that Lag column was a description of dataset used to calculate the slope column.

In the spreadsheet, the Slope(Hurst) column (col J), only one of those values should be chosen for the data set of 20 prices (in theory).
Kind of like saying, "which moving average should we look at?" This is to be determined by the user, and this is why we make InputLength, MinLag, MaxLag as inputs.
To be clear, the way that spreadsheet was built, MinLag was "hard coded" to = 3, but of course, this should be a variable for the user to choose when the solution is built with code (and its pretty easy to do...you can see the logic in the above VB code...its just a set of nested loops...just make sure to keep the various loop counters in line...i tried to name them meaningfully, instead of just using i, j, k etc..)

N and Lag have the same meaning in this sheet...but since "N" is used by lots of people to mean lots of things...we use "Lag" to give it some meaning here. N=Lag=Rolling Window Size

However, Lag does have meaning. A dataset first has a number of input values. In this case, there are 20 prices. To analyze this input data using Hurst, we are taking a rolling window of prices, within the larger dataset, and looking at how the data changes as the rolling window increases. So, lets say, with an input length of 20 (using standard sierra chart terminology, we have 20 prices), i might set the min lag to 3 and the max lag to 6. What do these lags mean? They are the size of the rolling windows, within the larger dataset, that we use to analyse the entire dataset.

In the tables over to the right, the staircase columns whose rolling ranges are being analyzed. So, Column O (Lag3) is looking at a rolling window of 3 values...so that col is looking at Lag=3 (RollingWindowSize=3) The values in that column are then averaged at the bottom. So, for a Lag (or, rolling window) of 3, we get an avg range of the rolling windows of 3 contiguous prices, and the avg standard deviation of those same sets of 3 prices, for the entire dataset defined by the input length (in this case, 20 prices). We do that again in cols P-->R, but with a different Lag (rolling window size). As the Lag increases (or, as the rolling window gets bigger), we expect the relationship (slope) between Log(avgRange/avgStDev) and Log(RollingWindowSize) to meaningfully define the data. The slope of the plot of Y-Log(R/S) vs X-Log(RollingWindowSize) is the "Hurst Exponent"....using the "rescaled range method".

We want to look at this indicator (Hurst) as a moving average, because trends in the data will come and go. Hurst picks up on whether the data is "trending" "mean reverting" or "random" by the slope of the Log(R/S) vs Log(Lag)...so intuitively, if the range is increasing faster then the stdev, as the rolling window size increases, then the slope will be larger and approach 1.
If the range vs its standard deviation is not increasing as the rolling window size increases, then hurst would define the data as "mean reverting" and slope would approach 0.
If the Data is "random" then the slope of this relationship will approach 0.5

Data in the natural world (in this case, financial price data) will form trends ephemerally (they come and go)....so this is why we want to calc and look at hurst like a moving average. I expect the Hurst value to spike when it picks up a trend...but i also expect those trends to be "short lived", which is why Hurst is kindof like an RSI indicator. Since financial data is not perfect (compared to other data in the natural world like climate data) this method will miss certain trends, and over-report others. Its just one more thing to look at in combo with other indicators.

I hope this helps..and if not, i'd be glad to answer any other questions you might have.

Regarding VB or VBA, i think the code just has a bunch of For / Next Loops, and variables & arrays storing data doing simple sum/avg math (in VB you can "resize" an array using the "redim" statement). There are no other complicated things going on...its just keeping the loops and various loop counters straight. Indenting the code properly will help.

for example
"Dim LogN() As Double" is creating an array variable "LogN" with unknown dimensions (). Those dimensions are set later in the code with a redim statement
InputData is an Excel Range object, but we are just using it as holding a column of data.

There might be a couple extra variables that are assigned data in a loop that are a waste, because that value just gets passed on to another variable immediately afterwards. I think there are a couple of those. I was looking at the step tables in the spreadsheet when i wrote the code, so i recreated everything i saw in the sheet...but there was some repetition that i now realize was a waste. Its not so bad..probably 4-5 lines of variable assignment code could be reduced to 1-2 in a couple of the loops...something like that.
Date Time Of Last Edit: 2017-03-21 20:06:25