Posted By: Paul_der_Zweite
Multi asset correlation - 02/18/19 17:23
Hi,
I want to check a list of assets for correlation. Each asset in the list should be checked with each asset in the list.
I don't want to write a time for every possibility, of course, but by while(asset(loop())
Unfortunately I can't get it to work yet
I would like a list, on which the following is shown to me:
asset a to asset b: Correlation x
asset a to asset c: Correlation x
asset a to asset d: Correlation x
and so on.
I tried the following, which doesn't work yet:
In my beginner version only ones appear (1.000000). *head scratch*
Does anyone have a tip?
I want to check a list of assets for correlation. Each asset in the list should be checked with each asset in the list.
I don't want to write a time for every possibility, of course, but by while(asset(loop())
Unfortunately I can't get it to work yet
I would like a list, on which the following is shown to me:
asset a to asset b: Correlation x
asset a to asset c: Correlation x
asset a to asset d: Correlation x
and so on.
I tried the following, which doesn't work yet:
Code:
function run() { BarPeriod = 240; LookBack = 300; StartDate = 2017; //EndDate = 2019; while(asset(loop("AUD/CAD","AUD/JPY","AUD/NZD","AUD/USD","CAD/CHF","CAD/JPY","CHF/JPY","Cocoa","Coffee","Copper","Corn","Cotton","Esp35","EuBund","EUR/AUD","EUR/CAD","EUR/CHF","EUR/GBP","EUR/HUF","EUR/JPY","EUR/NOK","EUR/NZD","Euro50","EUR/PLN","EUR/SEK","EUR/SGD","EUR/TRY","EUR/USD","Fra40","Gasol","GBP/AUD","GBP/CAD","GBP/CHF","GBP/JPY","GBP/NZD","GBP/USD","GER30","GerTec","GOLD","Jp225","LCrude","Neth25","NGas","NZD/CAD","NZD/CHF","NZD/JPY","NZD/USD","OJ","SGD/JPY","SILVER","Soybns","Sugar","Swi20","TRY/JPY","UK100","Usa500","UsaInd","UsaRus","UsaTB","UsaTec","UsaVix","USD/BRL","USD/CAD","USD/CHF","USD/CNH","USD/HUF","USD/JPY","USD/MXN","USD/NOK","USD/PLN","USD/RUB","USD/SEK","USD/SGD","USD/TRY","USD/ZAR","Wheat"))) vars price_asset_1 = series(price()); while(asset(loop("AUD/CAD","AUD/JPY","AUD/NZD","AUD/USD","CAD/CHF","CAD/JPY","CHF/JPY","Cocoa","Coffee","Copper","Corn","Cotton","Esp35","EuBund","EUR/AUD","EUR/CAD","EUR/CHF","EUR/GBP","EUR/HUF","EUR/JPY","EUR/NOK","EUR/NZD","Euro50","EUR/PLN","EUR/SEK","EUR/SGD","EUR/TRY","EUR/USD","Fra40","Gasol","GBP/AUD","GBP/CAD","GBP/CHF","GBP/JPY","GBP/NZD","GBP/USD","GER30","GerTec","GOLD","Jp225","LCrude","Neth25","NGas","NZD/CAD","NZD/CHF","NZD/JPY","NZD/USD","OJ","SGD/JPY","SILVER","Soybns","Sugar","Swi20","TRY/JPY","UK100","Usa500","UsaInd","UsaRus","UsaTB","UsaTec","UsaVix","USD/BRL","USD/CAD","USD/CHF","USD/CNH","USD/HUF","USD/JPY","USD/MXN","USD/NOK","USD/PLN","USD/RUB","USD/SEK","USD/SGD","USD/TRY","USD/ZAR","Wheat"))) vars price_asset_2 = series(price()); var corr = Correlation(price_asset_1, price_asset_2, 240); if(!is(LOOKBACK)) printf("n %f", corr); }
In my beginner version only ones appear (1.000000). *head scratch*
Does anyone have a tip?