correlation function problem

Questions about MultiCharts and user contributed studies.
User avatar
rokanten
Posts: 48
Joined: 29 Jul 2010
Location: south korea
Has thanked: 15 times

correlation function problem

Postby rokanten » 03 Dec 2012

Hi.

i am trying to use correlation function
to see the result between nikkei and s&p.
the problem is that there's some difference of holidays between japan and US,
so if i plot nikkei and s&p on one chart,
there shows up a blank day.(as i pointed it in the attached picture)
and then suddenly correlation between them becomes 0.

i used 'correlation(c of data1, c of data2,50)' code for this.
i tried some language to fix this, but my knowledge wans't enough.

can someone help me out here?

Regards.
Attachments
1.png
(34.14 KiB) Downloaded 518 times

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: correlation function problem

Postby sptrader » 03 Dec 2012

I've done similar correlation studies and I simply write something like:

Code: Select all

If data 1 <> 0 and data2 <> 0 then begin

That way any blank days (holidays) are skipped.

User avatar
rokanten
Posts: 48
Joined: 29 Jul 2010
Location: south korea
Has thanked: 15 times

Re: correlation function problem

Postby rokanten » 04 Dec 2012

@sptrader

thanks for reply.
but doesn't work that way.
i tried to plot "1" if there's any blank day, and plot "0" with no blank day
with this codes
" if c of data1<>0 and c of data2<>0 then val1=0 else val1=1;
plot1(val1); "
but it doesn't work.

anyway thanks for your reply. :)

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: correlation function problem

Postby Andrew MultiCharts » 04 Dec 2012

Hello rokanten,

I would recommend you to compile your own combined holiday list in QuoteManager *using one of the existing ones, that is not necessary for you), so you will see bars on your charts only when there are no holidays both in US and Japan, and there will be no calculation on the data 2 when there is a holiday on data 1 or vice versa, however this would affect all other charts, so that solution may not be a good one for you.
The other variant i can think of is to add a filter to your script not to calculate the script on particular dates, so it won't give you 0 result.

Both my suggestions are based on idea to skip calculation of the script on particular dates. If this is not what you looking for, please let me know.

User avatar
rokanten
Posts: 48
Joined: 29 Jul 2010
Location: south korea
Has thanked: 15 times

Re: correlation function problem

Postby rokanten » 04 Dec 2012

@Andrew MultiCharts

thanks for your suggestions.
but both of them are not the way i wanted.
the first one would be missing data, and the second one would be exhausting work.
thanks anyway.

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: correlation function problem

Postby Andrew MultiCharts » 05 Dec 2012

As for the second option, it should not be that hard:

Code: Select all

If date <> X or date <> Y or date <> Z or date <> ... then begin
*your script*
end;


Return to “MultiCharts”