Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (Nymphodora, AndrewAMD, Quad, TipmyPip), 889 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 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,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
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,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
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,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
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,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
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