logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
jjstein  
#1 Posted : Thursday, January 26, 2006 5:45:14 AM(UTC)
jjstein

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)
Given these two data arrays: x1:=Security("C:\\METASTOCK DATA\\US STOCKS\\C - D\\DIA",C); x2:=Security("C:\\METASTOCK DATA\\DJIA1941",C); How can I do these two things: 1. If at least 30 data points exist at a point in time, use X1, if not, use X2. 2. Conversely, if X2 is not current, then use X1. Thanks, --Johnathan
Jose  
#2 Posted : Thursday, January 26, 2006 12:36:25 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Unfortunately, once you place both Security references within any formula (such as within the If() function), MetaStock will restrict the available plot to the smallest data array. This can only be prevented with the use of an external dll function. However, you could try this: [code:1:ce585b16f5]x1:=Security("C:\\METASTOCK DATA\\US STOCKS\\C - D\\DIA",C); x2:=Security("C:\\METASTOCK DATA\\DJIA1941",C); bars1:=cum(IsDefined(x1)); bars2:=cum(IsDefined(x2)); If(bars2<30,x1,x2) [/code:1:ce585b16f5] jose '-)
jjstein  
#3 Posted : Thursday, January 26, 2006 7:19:41 PM(UTC)
jjstein

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)
I tried this: x1:=Security("C:\\METASTOCK DATA\\DJIA1940",C); x2:=Security("C:\\METASTOCK DATA\\US STOCKS\\C - D\\DIA",C); bars1:=Cum(IsDefined(x1)); bars2:=Cum(IsDefined(x2)); x:=If(bars2<30,x1,x2); ...but it still seems to restrict total data to the short series. Any other suggestions? --Johnathan
mstt  
#4 Posted : Thursday, January 26, 2006 9:15:00 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Jonathan Try something along these lines. I've noticed that some functions in Patrick's Forum DLL substitute zero in place of N/A, and I think this "feature" can be used here to go one better than the ineffective IsDefined() function. What you may be left with if you are introducing some extra N/A periods is an unwanted zero plot at the left of the chart. This can easily be attended to with ValueWhen(1,x>0,x), which forces leading zeros to N/A and retains valid prices just as they were. Of course this method should not be used where valid values can also be zero. x1:=Security("C:\\METASTOCK DATA\\DJIA1940",C); x2:=Security("C:\\METASTOCK DATA\\US STOCKS\\C - D\\DIA",C); x1:=ExtFml("Forum.Sum",x1,1); x2:=ExtFml("Forum.Sum",x2,1); x:=If(x2=0,x1,x2); x; Roy MetaStock Tips & Tools
jjstein  
#5 Posted : Friday, January 27, 2006 6:31:27 PM(UTC)
jjstein

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)
Roy, That seems to work... x1:=Security("C:\\METASTOCK DATA\\DJIA1940",C); x2:=Security("C:\\METASTOCK DATA\\US STOCKS\\C - D\\DIA",C); x1:=ExtFml("Forum.Sum",x1,1); x2:=ExtFml("Forum.Sum",x2,1); x3:=ExtFml("Forum.Sum",x2,30); x:=If(x3=0,x1,x2); { Other calcs here } Have never used "forum.dll" before, but it seemed straightforward. The above is supposed to make sure that there are at least 30 data points (for use with other calcs in the formula). Thanks! --Johnathan[size=9:82b3ae2b5f][/size:82b3ae2b5f]
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.