Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (SBGuy), 652 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Correlation -1.#IND00 #476021
01/18/19 13:57
01/18/19 13:57
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Hi guys,

why using the code below I see this message?

Code:
vars serie1, serie2, serie3;

function run(){
	
	StartDate = 2013;
	EndDate = 2018;

	LookBack = 0;
	BarPeriod = 1;
	assetList("Assets");
	
	
	asset("GBP/USD");
	serie2 = series(priceClose());
	
	asset("EUR/USD");
	serie3 = series(priceClose());
	
	printf("n %f", Correlation(serie2, serie3, 240));
}




Attached Files ind.png
Last edited by tradingest; 01/18/19 14:07.
Re: Correlation -1.#IND00 [Re: tradingest] #476023
01/19/19 16:05
01/19/19 16:05
Joined: Oct 2018
Posts: 70
AZ
C
chsmac85 Offline
Junior Member
chsmac85  Offline
Junior Member
C

Joined: Oct 2018
Posts: 70
AZ
#IND means that the result is indeterminate. Most likely based on this operation it is due to dividing by 0.

Looking at the formula for correlation, this could be because the standard deviation of asset 1 or asset 2 is 0 or that the series themselves are empty.

I'm going to take a guess. Can you confirm that the length of the two series is the same? Perhaps there is an issue with how correlation calculations are figured when one series is of a different length than an other series?

Re: Correlation -1.#IND00 [Re: chsmac85] #476025
01/19/19 16:44
01/19/19 16:44
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Lookback should not be set to zero. Try a higher number.

Re: Correlation -1.#IND00 [Re: AndrewAMD] #476032
01/20/19 15:38
01/20/19 15:38
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Originally Posted By: AndrewAMD
Lookback should not be set to zero. Try a higher number.


Doesn't works also with lookback 1000...

can you help me?

Re: Correlation -1.#IND00 [Re: tradingest] #476034
01/20/19 18:01
01/20/19 18:01
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
You also need to prevent printing while run() is being used during the Lookback period. You can check for this with is(LOOKBACK).

Behold:
Code:
function run(){
	assetList("AssetsOanda.csv");
	BarPeriod = 1;
	LookBack = 300;
	StartDate = 2013;
	EndDate = 2018;
	
	asset("GBP/USD");
	vars series2 = series(priceClose());
	
	asset("EUR/USD");
	vars series3 = series(priceClose());

	var cor = Correlation(series2, series3, 240);
	
	if(!is(LOOKBACK))
		printf("\n %f", cor);
}


Re: Correlation -1.#IND00 [Re: AndrewAMD] #476035
01/20/19 18:05
01/20/19 18:05
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Thanks so much AndrewAMD

thanks thanks thanks

Re: Correlation -1.#IND00 [Re: tradingest] #476036
01/20/19 18:55
01/20/19 18:55
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Andrew,

I read the manual but I can not quite understand the value inserted within the correlation ... should indicate the bars so if barperiod = 1 and set 240 I should get the correlation relative to 4 hour I say well?

Re: Correlation -1.#IND00 [Re: tradingest] #476037
01/20/19 19:02
01/20/19 19:02
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Originally Posted By: tradingest
Andrew,

I read the manual but I can not quite understand the value inserted within the correlation ... should indicate the bars so if barperiod = 1 and set 240 I should get the correlation relative to 4 hour I say well?

The way you wrote your code, you are checking for the correlation between the two assets, for the one-minute bars, for the past 240 samples, which would be the last four hours. That is, you gain a sample and lose a sample once a minute.

Re: Correlation -1.#IND00 [Re: AndrewAMD] #476038
01/21/19 01:07
01/21/19 01:07
Joined: Oct 2018
Posts: 70
AZ
C
chsmac85 Offline
Junior Member
chsmac85  Offline
Junior Member
C

Joined: Oct 2018
Posts: 70
AZ
Would taking the average of that sequence yield a meaningful value?

Something like the average correlation in a resampled population.

Re: Correlation -1.#IND00 [Re: chsmac85] #476041
01/21/19 16:37
01/21/19 16:37
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Originally Posted By: chsmac85
Would taking the average of that sequence yield a meaningful value?

Something like the average correlation in a resampled population.
I have not attempted this, so I'm not sure.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1