roll_hurst | R Documentation |
Calculate a time series of Hurst exponents over a rolling look-back interval.
roll_hurst(ohlc, look_back = 11)
ohlc |
An OHLC time series of prices in xts format. |
look_back |
The size of the look-back interval, equal to the number of rows of data used for aggregating the OHLC prices. |
The function roll_hurst()
calculates a time series of
Hurst exponents from OHLC prices, over a rolling look-back
interval.
The Hurst exponent is defined as the logarithm of the ratio of the price range, divided by the standard deviation of returns, and divided by the logarithm of the interval length.
The function roll_hurst()
doesn't use the same definition as the
rescaled range definition of the Hurst exponent.
First, because the price range is calculated using High and
Low prices, which produces bigger range values, and higher
Hurst exponent estimates.
Second, because the Hurst exponent is estimated using a single
aggregation interval, instead of multiple intervals in the rescaled range
definition.
The rationale for using a different definition of the Hurst exponent is that it's designed to be a technical indicator for use as input into trading models, rather than an estimator for statistical analysis.
An xts time series with a single column and the same number of
rows as the argument ohlc
.
# Calculate rolling Hurst for SPY in March 2009
hurst_rolling <- roll_hurst(ohlc=HighFreq::SPY["2009-03"], look_back=11)
chart_Series(hurst_rolling["2009-03-10/2009-03-12"], name="SPY hurst_rolling")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.