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

Notification

Icon
Error

Options
Go to last post Go to first unread
chinna  
#1 Posted : Sunday, June 19, 2005 12:56:38 AM(UTC)
chinna

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 6/17/2005(UTC)
Posts: 1

Hi there, I have started coding my explorer formula to try and Identify the highest price since previous peak. The formula works on the following principles. 1. A short term up trend (STUT) is signalled if price breaks the previous days high on two consecutive days. 2. A short term down trent (STDT) is signalled if price breaks the previous days low on two consecutive days. 3. A peak is defined as the highest price between a short-term up trend (STUT) and a short-term down trend (STDT). I have started coding this formlua and have limited success. See formula below: - - - - - - - - - - - - - STUT := H > Ref(H, -1) AND Ref(H, -1) > Ref(H, -2); {Short term uptrend} STDT := L < Ref(L, -1) AND Ref(L, -1) < Ref(L, -2); {Short term downtrend} Init:=Cum(STUT+STDT>-1)=1; {Only used to establish an initial trend since records begin} INSTUT:= (BarsSince(Init OR STUT)<BarsSince(Init OR STDT)); {In uptrend} ESTUT := (Ref(INSTUT,-1)=0 AND INSTUT); {First entered uptrend} ESTDT := (Ref(INSTUT,-1)=1 AND INSTUT=0); {First entered downtrend} PPeak := If(ESTDT = 1, HighestSince(1, ESTUT, H), PREV); {Previous Peak, highest high since uptrend began and trend reversed} PPeak - - - - - - - - - - -- - - - - - - - - The results returned by Metastock exporer does not return the results that I expect. Is any body able to provide any assistance? Many Thanks
wabbit  
#2 Posted : Sunday, June 19, 2005 2:06:50 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)
Chinna, Your code seems to work fine for me, as an indicator. One suggestion: use something along the lines of: trendLength:=2; {Short term uptrend} STUT:=Sum(H>Ref(H,-1),trendLength)>=trendLength; {Short term downtrend} STDT:=Sum(L<Ref(L,-1),trendLength)>=trendLength; it is far more flexible and doesnt have a heap of nested ANDs, ORs or IFs. If you want to redefine the length of the trend you only need to change one variable. You might even want to use an Input() function if you think this figure will change often. Onto the exploration... what do you have in your filter? I assume you are looking for a high crossing the indicator? try: x:=H>fml("my Indicator"); x and alert(x=0,2) Hope this helps. wabbit :D P.S> Good first post. Thankyou.
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.