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

Notification

Icon
Error

Options
Go to last post Go to first unread
bullenr  
#1 Posted : Saturday, April 5, 2008 11:49:06 AM(UTC)
bullenr

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/5/2007(UTC)
Posts: 10

When you use this formula: (ROC(C,260,%)+ROC(C,130,%)+ROC(C,65,%)+ROC(C,22,%))/4 in the Explorer it rejects securities that lack 261 days of data. Is there a way to write something like

if there is at least 261 days of data then (ROC(C,260,%)+ROC(C,130,%)+ROC(C,65,%)+ROC(C,22,%))/4
else if there is at least 131 days of data then (ROC(C,130,%)+ROC(C,65,%)+ROC(C,22,%))/3
else if there is at least 66 days of data then (ROC(C,65,%)+ROC(C,22,%))/2
and so on....

so that short securities would not get rejected?

johnl  
#2 Posted : Saturday, April 5, 2008 7:48:46 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

Try Isdefined(mov(c,20,s)). It will give you "1" if there are 20 periods of data loaded.
{Not tested} Post your results. Thanks.
bullenr  
#3 Posted : Sunday, April 6, 2008 7:41:09 AM(UTC)
bullenr

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/5/2007(UTC)
Posts: 10

I tried it and it fails the same way as the underlying function. IsDefined(ROC(CLOSE,260,%)) fails with the message "Error in Column A: Period value out of range in ROC() function." on all securities having 260 days or less and they are rejected.

There are two reasons why this is not a good thing. First, by rejecting the security outright the Explorer prevents me from calculating some other substitute function for the security that would prevent the security from being rejected. Second, it prevents me from using the exploration to get the complete list of all securities in the folder; if I want this result as well, I need to run a separate exploration that has no rejections.

Maybe I am not using the function correctly. Any idea?

wabbit  
#4 Posted : Sunday, April 6, 2008 8:11:21 AM(UTC)
wabbit

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)
bullenr,

The IsDefined() function is not going to help you here; you need to use an external function to return a zero value when the ROC() function is undefined. Read this thread (http://forum.equis.com/forums/permalink/21013/20995/ShowThread.aspx#20995 several explorations.


Hope this helps.

wabbit [:D]
bullenr  
#5 Posted : Sunday, April 6, 2008 9:07:41 AM(UTC)
bullenr

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/5/2007(UTC)
Posts: 10

Right, isdefined() is useless. But by some miracle, the below works. It returns N/A when the security is less than 261 days and returns the ROC otherwise. Any idea why this works?

M:=Ref(C,0)/Ref(C,-LastValue(Min(260,Cum(1))))-1;

If(Cum(1)<261,0,M);

wabbit  
#6 Posted : Sunday, April 6, 2008 6:04:48 PM(UTC)
wabbit

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:
M:=Ref(C,0)/Ref(C,-LastValue(Min(260,Cum(1))))-1;
If(Cum(1)<261,0,M);

Looking at the expression inside the denominator, LastValue(Min(260,Cum(1)); the code is returning the smallest value, Min(), of 260 and the number of bars on the chart, Cum(1), with the LastValue() "converting" the value from a data array to an integer.This number is then used in the Ref() expression to return a value on either; the 261st bar of the chart if there are more than 260 bars, or on the last bar if there are less than 260 bars.

It's probably not the best explanation, but have a play with some charts with differing amounts of data and see the what happens for yourself.

It doesn't completely solve the original issue, but you should be gaining more insight into how MS is dealing with the "definition" periods of data arrays.


Hope this helps.

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.