+1 888 340 6572

# JRC_fractal_dim

Article/Author: Mark Jurik, Jurik Research www.jurikres.com

File Includes:
Function - JRC_fractal_dim
Indicator - JRC Fractal dim

Category: Function > JRC_fractal_dim

Description: There is a weak and a strong way to measure the random quality of a time series.

The weak way is to use the random walk index (RWI). You can download it from the Omega web site. It makes the assumption that the market is moving randomly with an average distance D per move and proposes an amount the market should have changed over N bars of time. If the market has traveled less, then the action is considered random, otherwise it's considered trending.

The problem with this method is that taking the average distance is valid for a Normal (Gaussian) distribution of price activity. However, price action is rarely Normal, with large price jumps occuring much more frequently than a Normal distribution would expect. Consequently, big jumps throw the RWI way off, producing invalid results.

The strong way is to not make any assumption regarding the distribution of price changes and, instead, measure the fractal dimension of the time series. Fractal Dimension requires a lot of data to be accurate. If you are trading 30 minute bars, use a multi-chart where this indicator is running on 5 minute bars and you are trading on 30 minute bars.

The following table shows how to interpret the results....

Fractal Dimen. Autocorrelation[1] Fractal Eff. Description
----------------------------------------------------------------------
2.0 -1.0 0.0 congestion
1.5 0.0 0.5 random walk
1.0 1.0 1.0 trend
----------------------------------------------------------------------

Inputs:

EasyLanguage Code:
```{
---------------------------------------------------------------------
FUNCTION:	JRC_FRACTAL_DIM
PURPOSE:	THE FRACTAL DIMENSION OF A SERIES OF OHLC BARS
INPUTS:		FRAC.SIZ > 0	NUMBER OF BARS IN A FRACTAL.
DETERMINES SCALE RESOLUTION
FRAC.CNT > 0	NUMBER OF FRACTALS TO AVERAGE,
MORE GIVES BETTER ACCURACY.

MAXBARSBACK:	MUST BE >= FRAC.SIZ * FRAC.CNT
INHERENT LAG:	= 0.5 * FRAC.SIZ * FRAC.CNT

AUTHOR:		MARK JURIK,  2 OCT 96
YOU MAY COPY THIS CODE FOR PERSONAL USE ONLY.
--------------------------------------------------------------------
}
INPUTS:	FRAC.SIZ	( NUMERIC ) ,
FRAC.CNT 	( NUMERIC ) ;

VARS:	SMLRANGE	( 0 ) ,
BIGRANGE	( 0 ) ,
SMALLSUM	( 0 ) ,
WINDOW1		( (FRAC.CNT-1)*FRAC.SIZ ) ,
WINDOW2		( FRAC.CNT * FRAC.SIZ ) ,
NLOG		( LOG ( FRAC.CNT ) ) ;

SMLRANGE = MAXLIST ( C[FRAC.SIZ] , HIGHEST ( H , FRAC.SIZ ) )
- MINLIST ( C[FRAC.SIZ] , LOWEST  ( L , FRAC.SIZ ) ) ;

IF CURRENTBAR > WINDOW1
THEN 	BEGIN
BIGRANGE = MAXLIST ( C[WINDOW2] , HIGHEST ( H , WINDOW2 ) )
- MINLIST ( C[WINDOW2] , LOWEST  ( L , WINDOW2 ) ) ;
SMALLSUM = SMALLSUM + SMLRANGE - SMLRANGE [ WINDOW1 ] ;
JRC_FRACTAL_DIM = 2 - (LOG(BIGRANGE/(SMALLSUM/WINDOW1))/NLOG);
END
ELSE	BEGIN
SMALLSUM = SMALLSUM + SMLRANGE ;
JRC_FRACTAL_DIM = 1.5;  {INITIALLY, ASSUME RANDOM WALK}
END;```