Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
6 registered members (TipmyPip, Niels, dBc, Ed_Love, 3run, 1 invisible), 17,843 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
understanding the FractalDimension code #479652
04/15/20 20:11
04/15/20 20:11
Joined: Mar 2020
Posts: 19
London
H
hola123 Offline OP
Newbie
hola123  Offline OP
Newbie
H

Joined: Mar 2020
Posts: 19
London
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.);
}

Re: understanding the FractalDimension code [Re: hola123] #479657
04/16/20 09:51
04/16/20 09:51
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
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

Re: understanding the FractalDimension code [Re: hola123] #479670
04/16/20 21:26
04/16/20 21:26
Joined: Mar 2020
Posts: 19
London
H
hola123 Offline OP
Newbie
hola123  Offline OP
Newbie
H

Joined: Mar 2020
Posts: 19
London
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?


Moderated by  Petra 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1