understanding the FractalDimension code

Posted By: hola123

understanding the FractalDimension code - 04/15/20 20:11

I am trying to understand the section of code below.

So from the manual I take it the Data parameter will be the prices & Period the number of observations.

I however do not follow the line below,

MaxVal(Data+Period2,Period2)

It is the Data+Period2 part that confuses me. If Data is a series of prices & Period2 is an integer is this line of code just adding a scalar value to the series of prices?




var FractalDimension(var* Data,int Period)
{
checkLookBack(2*Period);
Period &= ~1;
int Period2 = Max(1,Period/2);
var N1 = (MaxVal(Data,Period2)-MinVal(Data,Period2))/Period2;
var N2 = (MaxVal(Data+Period2,Period2)-MinVal(Data+Period2,Period2))/Period2;
var N3 = (MaxVal(Data,Period)-MinVal(Data,Period))/Period;
if(N1+N2 <= 0. || N3 <= 0.) return 1.;
return (log(N1+N2)-log(N3))/log(2.);
}
Posted By: jcl

Re: understanding the FractalDimension code - 04/16/20 09:51

It adds an offset to the begin of the series. This is a specialty of C/C++.

Read about it here: https://manual.zorro-project.com/series.htm
Posted By: hola123

Re: understanding the FractalDimension code - 04/16/20 21:26

thanks for the reply. Yes that would make much more sense.

If we say Period is 100 and then Period2 is 50

The line MaxVal(Data, Period2) is that taking the max value over the first 50 periods of Data (1 to 50)?
Similarly for MaxVal(Data, Period) is taking the max value over the last 100 periods of Data (1 to 100)?
Lastly for MaxVal(Data + Period2, Period2) is taking the max value over periods 51 to 100?
© 2024 lite-C Forums