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

Notification

Icon
Error

Options
Go to last post Go to first unread
gorachand  
#1 Posted : Saturday, January 3, 2015 8:36:46 AM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 106

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
This is part of the code by Mr.Jose d'Silva available at http://www.metastocktool.../MetaStock/TrendLine.txt
In this code for an automatic adjustable trendline

{define events}
pr:=If(pr=1,O,If(pr=2,H,If(pr=3,L,If(pr=5,V,
If(pr=6,MP(),If(pr=7,P,C))))));
price1:=pr;
price2:=pr;
time1:=price1>Ref(HHV(price1,pds),-1);
time2:=price2<Ref(LLV(price2,pds),-1);

{restrict to last events}
time1:=time1
 AND Cum(time1)=LastValue(Cum(time1));
time2:=time2
 AND Cum(time2)=LastValue(Cum(time2));

he declares a variable twice. It is the rule of any programming language that
a variable should be declared once and only once.

But the code is correct as---he is an expert and the code works--
(I have tried it out on my machine)
Could somebody explain this apparent anomaly to me?

Regards,

Dr.Chatterjee
mstt  
#2 Posted : Saturday, January 3, 2015 7:43:25 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)
Hi gorachand MetaStock allows you to redefine existing variable names several times if you need to. This can be a modified definition of an existing variable or it can be a completely new definition. The only proviso is that you must not change an original or subsequent definition if that definition is still required later in the flow or sequence of the formula (an indicator or expert etc.). Some of my Trade Equity indicators define over 60 variables but only use the maximum allowable number of 20 different variable names. All 900 or so Multi-Frame indicators also have have more than 20 variable definitions while keeping within the 20 variable limit. Roy
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.