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

Notification

Icon
Error

Options
Go to last post Go to first unread
TMS1234  
#1 Posted : Monday, February 12, 2007 11:49:59 AM(UTC)
TMS1234

Rank: Newbie

Groups: Registered, Registered Users
Joined: 2/12/2007(UTC)
Posts: 2

Hi all,

I want to write some variables which may refer to each other, However,
it seems that metastock does not allow me to do so.

a:=(cum(1)=1)*100 + ref(b, -1)+ if(something);
b:=(cum(1)=1)*100 + ref(a, -1)+ if(something);

In this case, a needs ref(b, -1) and b needs ref(a, -1). What can i do
if i want to do so? Can anybody help me?

Thank you!!!
Thomas
wabbit  
#2 Posted : Friday, February 16, 2007 5:30:09 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)
Thomas,

No system in the world will allow you to use a circular reference. What you should consider doing is (if it fits in with the logic of your system) is to create a third variable and have both the 'a' function and the 'b' function call the value from the newly created variable.

It would also help if you could provide a little more information on exactly what your 'system' is supposed to be achieveing; there might be better alternatives but we don't know for sure what you are trying to do so cannot make any other recommendations.


Hope this helps.

wabbit [:D]

TMS1234  
#3 Posted : Saturday, February 17, 2007 2:05:29 AM(UTC)
TMS1234

Rank: Newbie

Groups: Registered, Registered Users
Joined: 2/12/2007(UTC)
Posts: 2

Hi wabbit,

Thank you for you reply. Actually what i want to do is to build my own zigzag to find the recent high and low, just like PeakBars. I don't want to use the build in zigzag so i try to do it myself

percentage:=3;

{Determine whether it is a rising trend or falling trend, 1= rising, -1=falling}
trend:=
If(PREV=1,
If((ref(recenthigh, -1)-C)*100/(ref(recenthigh, -1)+0.0001)<percentage,
PREV,
-1
),
If((C-ref(recentlow, -1))*100/(ref(recentlow, -1)+0.0001)<percentage,
PREV,
1
)
);

{Find the recent low}
recentlow:= (Cum(1)=1)*C+
If(trend=-1),
If(Ref(trend, -1)=1,
C,
If(C<PREV,
C,
PREV
)
),
PREV
);

{Find the recent high}
recenthigh:= (Cum(1)=1)*C+
If(trend=1),
If(Ref(trend, -1)=-1,
C,
If(C>PREV,
C,
PREV
)
),
PREV
);

Here trend needs recenthigh and recentlow, and recenthigh and recentlow needs trends. That's what i mean multiple reference. If I am not allowed to write something like this, then what can i do if I want to write something like zigzag?

Thank you!
Thomas

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.