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

Notification

Icon
Error

Options
Go to last post Go to first unread
kkchan  
#1 Posted : Thursday, June 15, 2006 5:59:04 PM(UTC)
kkchan

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/22/2005(UTC)
Posts: 12

How to write the formula: When MA10 upcross MA20, then compare the L with the C of the last (MA10 upcross MA20). I am fresh to MetaStock. Could anybody help? Thanks
wabbit  
#2 Posted : Friday, June 16, 2006 12:21:07 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)
kkchan, Here at the forum, instead of just giving you the answers to the simple problems, we like to ensure that you know more, and start to learn to harness the power and technical aspects of MetaStock. Please have a thorough read of the MS Users Manual that was shipped with your copy of MetaStock. There is a lot of really good information in the book, in fact, enough there for you to answer this problem yourself. Then there is the Equis Formula Primer (available free from the downloads section of the forum). This is more of a self study guide through the basics of writing MS Formulas, like you want to achieve to answer your problem. Please attempt both of these and try to write your own code. If your code doesn't work like it should, then post back here, with a detailed explanation of what you are trying to achieve, and the most recent version of your code. You will find that people will give you their time to help you and explain the process. This is the only way you learn to program in MS. In the mean time, I will start you off.... MA10:=Mov(C,10,S); MA20:=Mov(C,20,S); Cross(MA10,MA20); {then I dont understand what you want to do with the Low and Close comparison} Hope this helps. wabbit :D
StorkBite  
#3 Posted : Friday, June 16, 2006 4:09:47 AM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
Maybe like this?? MA10:=Mov(C,10,S); MA20:=Mov(C,20,S); Cond1:=Cross(MA10,MA20); Cond2:=C>L; Cond1 AND Cond2
kkchan  
#4 Posted : Friday, June 16, 2006 4:23:49 PM(UTC)
kkchan

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/22/2005(UTC)
Posts: 12

Thank you wabbit & Storkbite. I read the books already. However, it is sth different between readings and real practice. Right? Actually, I wanna create a buy-in signal under 2 conditions: condition(a): when MA10 cross above MA20 condition(b): When (a) happens and the L of that day is higher than the C of last time when (a) took place(i.e. previous cross of MA10 & MA20). I wrote: MA10:=Mov(C,10,S); MA20:=Mov(C,20,S); UP:=Cross(MA10,MA20); LastX:=Ref(UP,-1); CofLastX:=ValueWhen(1,LastX,C); UP AND L>CofLastX But it seems not quite what I want. Could U guys modify it????
StorkBite  
#5 Posted : Friday, June 16, 2006 5:21:21 PM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
What about something like this? [code:1:c21825c015]MA10:=Mov(C,10,S); MA20:=Mov(C,20,S); Cond1:=Cross(MA10,MA20); Cond2a:=Ref(L,-LastValue(BarsSince(Cond1))); Cond2b:=Ref(C,-LastValue(HighestSinceBars(2+1,Cond1,LastValue(Cum(Cond1))-Cum(Cond1)+1))); Cond2:=Cond2a>Cond2b; Cond1 AND Cond2[/code:1:c21825c015]
wabbit  
#6 Posted : Saturday, June 17, 2006 1:36:25 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)
This is my take on it.... Hope it helps. --8<----------------------- MA10:=Mov(C,10,S); MA20:=Mov(C,20,S); x:=Cross(MA10,MA20); x AND L>ValueWhen(2,x,C); --8<----------------------- wabbit :D
henry1224  
#7 Posted : Saturday, June 17, 2006 2:40:31 AM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
sma1:=Mov(C,140,S); sma2:=Mov(C,10,S); a:=If(C>Max(sma1,sma2),1,If(C<Min(sma1,sma2),-1,0)); {Long entry signal} a=1 and Ref(A,-1)<1 sma1:=Mov(C,140,S); sma2:=Mov(C,10,S); a:=If(C>Max(sma1,sma2),1,If(C<Min(sma1,sma2),-1,0)); {Short entry signal} a=-1 and Ref(A,-1)>-1 sma1:=Mov(C,140,S); sma2:=Mov(C,10,S); a:=If(C>Max(sma1,sma2),1,If(C<Min(sma1,sma2),-1,0)); {Long exit signal} a=0 and Ref(A,-1)=1 sma1:=Mov(C,140,S); sma2:=Mov(C,10,S); a:=If(C>Max(sma1,sma2),1,If(C<Min(sma1,sma2),-1,0)); {Short exit signal} a=0 and Ref(A,-1)=-1 the system is designed to trade long when the close is above the higher of the 2 sma's, exit long when the close crosses below one of the sma's, goes short when the close is below the minimum of the 2 sma's and exits short when the close crosses above the lowest sma. this system has an advantage over a simple cross over system, it filters out noisy trades by trading with a trend
StorkBite  
#8 Posted : Saturday, June 17, 2006 3:10:21 AM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
Wabbit wrote:
This is my take on it.... Hope it helps. --8<----------------------- MA10:=Mov(C,10,S); MA20:=Mov(C,20,S); x:=Cross(MA10,MA20); x AND L>ValueWhen(2,x,C); --8<-----------------------
Wabbit... you show off... what was wrong with my long, complex version? lol! :P
wabbit  
#9 Posted : Saturday, June 17, 2006 3:22:37 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)
Its long and complex! KISS wabbit :D
kkchan  
#10 Posted : Saturday, June 17, 2006 7:43:24 AM(UTC)
kkchan

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/22/2005(UTC)
Posts: 12

U guys really kind enough!!! I will test all your advice & for sure, I learn alot. T h a n k y o u !!!!!!
StorkBite  
#11 Posted : Saturday, June 17, 2006 9:03:10 AM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
Yep... you've been "kissed" by a wabbit. :yuk:
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.