Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 1/20/2012(UTC) Posts: 5
|
Hi Guys
I'm trying to create an expert advisor that shows me when the correlation between 2 securities is negative and less than a specific number. In this case I am looking at the correlation between US Dollar Index futures (Independent variable) and Crude Oil futures (dependent variable) using continuous date and I'm looking for times when the correlation between them is < -0.60. I entered the below into expert advisr and then attach to a chart I have setup with both price plots. The expert advisor is supposed to place a symbol under the price plot in all cases when correlation < -0.6, however, ithe results are coming up incosistent. Often times the expert advisor will place a symbol on the chart in areas where the correlation is > -0.6 and well into positive territory. Can someone help me out with this? I've made sure to load the same amount of data for both charts starting with the same date so I'm not sure what else I need to do .
sec2:=Security("C:\Metastock Data\Intermarket Research\@:CLc1#I",C);
sec1:=Security("C:\Metastock Data\Intermarket Research\@:DXc1#I",C);
Correl(sec1,sec2,40,0)<-0.6
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
scocci357 wrote:Hi Guys I'm trying to create an expert advisor that shows me when the correlation between 2 securities is negative and less than a specific number. In this case I am looking at the correlation between US Dollar Index futures (Independent variable) and Crude Oil futures (dependent variable) using continuous date and I'm looking for times when the correlation between them is < -0.60. I entered the below into expert advisr and then attach to a chart I have setup with both price plots. The expert advisor is supposed to place a symbol under the price plot in all cases when correlation < -0.6, however, ithe results are coming up incosistent. Often times the expert advisor will place a symbol on the chart in areas where the correlation is > -0.6 and well into positive territory. Can someone help me out with this? I've made sure to load the same amount of data for both charts starting with the same date so I'm not sure what else I need to do .
sec2:=Security("C:\Metastock Data\Intermarket Research\@:CLc1#I",C); sec1:=Security("C:\Metastock Data\Intermarket Research\@:DXc1#I",C); Correl(sec1,sec2,40,0)<-0.6 Seems there is a problem with some of the original post not being loaded? Or is that just me? wabbit [:D] P.S. I see the forum is parsing everything between LT and GT as HTML tags, therefore dropping them from the visible part of the original post, but then does allow them in quoted replies. Sigh. Doesn't happen in phpBBs does it?
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 1/20/2012(UTC) Posts: 5
|
Wow just read my original post and noticed a lot of stuff in the text is missing. Basically I am trying to create an expert advisor that would show me when the correlation between the US Dollar Index Futures and Crude Oil futures is less than -0.60. When I try the code in my original post the results are inconsistent ? I would like to do a lot more intermarket research so I appreciate any input you guys can provide to help me get on the right track here with this and figure out what I'm doing wrong.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Switch off any other symbol codes in the EA and see if the problem is still happening. If so, please post the chart, and all of the associated code.
wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
Put your code between these two lines, but take out the space after the frist asterisk:
* code*
* /code*
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 1/20/2012(UTC) Posts: 5
|
Sorry Guys. I'm confused as to what is being asked. If I create a new expert advisor and under the highlight tab add the below to see when the correlation between these 2 securities is less than a certain amount (in this case -0.60) I would expect that it would highlight bars on the dependent security where this is the case, however, instead it is also highlighting bars whereby the correlation is well above -0.6 .
sec2:=Security("C:\Metastock Data\Intermarket Research\@:CLc1#I",C);
sec1:=Security("C:\Metastock Data\Intermarket Research\@:DXc1#I",C);
Correl(sec1,sec2,40,0)<-0.6
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Code:
sec2:=Security("C:\Metastock Data\Intermarket Research\@:CLc1#I",C);
sec1:=Security("C:\Metastock Data\Intermarket Research\@:DXc1#I",C);
Correl(sec1,sec2,40,0)<-0.6
will only highlight the instances where the correlation is less than -0.6 How are you determining the correlation is different? If you think its the internal function which is having issues, rewrite the code from scratch and see if it produces different results: Code:
x:=Security("C:\Metastock Data\Intermarket Research\@:CLc1#I",C);
y:=Security("C:\Metastock Data\Intermarket Research\@:DXc1#I",C);
n:=40;
num:=Sum(x*y,n)-n*Mov(x,n,S)*Mov(y,n,S);
den:=n*Stdev(x,n)*Stdev(y,n);
{plot}
num/Max(den,Power(10,-8));
If you're still worried about the MS Stdev() function in the above code, it can be replaced with its first-principles counterpart found here : http://forum.equis.com/forums/thread/37398.aspx
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 1/20/2012(UTC) Posts: 5
|
Thanks Wabbit. Dumb question- how do I post/attach an annotated chart?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Upload the image to a publicly visible server e.g. your ISP may provide you with some web space, or there are many free image sharing servers, e.g. ImageShack, TinyPic, PhotoBucket etc. Post the link to where the image is hosted, e.g. Code:
[img]http://www.myServer.com/myPicture.png[/img]
wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Upload the image to a publicly visible server e.g. your ISP may provide you with some web space, or there are many free image sharing servers, e.g. ImageShack, TinyPic, PhotoBucket etc. Post the link to where the image is hosted, e.g. Code:
[ img]http://www.myServer.com/myPicture.png[/img ]
wabbit [:D]
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.