Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, rki), 390 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 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: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
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 | chip programmers | 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