Thursday, October 15, 2009

Rescaled Range Analysis

The Rescaled Range Analysis is an interesting statistical tool to detect long-range dependence in a time-series, and it also provides a method to estimate the Hurst Exponent. I have detailed to some extent this method on my other blog at this address.

Having estimated the Hurst Exponent, I was then able to write a Fractalised Moving Average, very much in the style of the FRASMA, except that this one, called RS_FRASMA, used the estimation of the Hurst Exponent coming from a Rescaled Range Analysis.
Unfortunately, this analysis is rather demanding in terms of computing power and time, I was therefore limited to small sample of values and even then, the processing time is quite long, furthermore, the result of the estimation is not very good, and not good enough anyway to be usable in terms of a fractional bands type of indicator.
Nevertheless, the RS_FRASMA may still be of some interest, if only in comparison with other MAs, and I therefore uploaded a script in MQL4 at this address.

The logic of the RS_FRASMA is similar to the one at work in the FRASMA: An SMA is modified by multiplication of its speed with a factor alpha defined as such:

Where H is the Hurst Exponent.

Here is what it looks like, the red curve is the RS_FRASMA, the yellow one is the FRASMA, and the blue one is an SMA, all with unmodified speed of 30:

The parameters of RS_FRASMA are:
period (integer): The size of the sample on which the Rescaled Range Analysis is performed, it must be a power of 2 (4,8,16,32,64,128,...), the default is 64, and in consideration of the limited computing power of MT4, I don't advise going higher than 256.
normal_speed (integer): This is the normal speed of the Moving Average before it is modified by the Hurst Parameter.
PIP_Convertor (integer): The factor necessary to convert real price to PIPS, default is 10000 (for EUR/USD)
type_data (0,1,2,3,4,5 or 6): This is the type of price the indicator will consider (0=CLOSE, 1=OPEN, 2=HIGH, 3=LOW, 4=MEDIAN, 5=TYPICAL, 6=WEIGHTED), default is 0.