Discussions
»
Product and Service Development
»
Formula Assistance
»
MACD (5,35,5) plus crossing zero line for the explorer function
Rank: Newbie
Groups: Guests
Joined: 7/28/2014(UTC) Posts: 1
|
Hi, Im a newbie n MetaStock, trying to use the explorer function. I want to write an explorer with MACD (5,35,5) plus MACD line CROSSING zero line. Read some posts here and formula book, but still it didn't work.
Here is the explorer code: Col A: Col. Name:C Desc.:CLOSE
Col B: Col. Name:MACD Desc.: nd1:=5; nd2:=35; nmov:=5; zeroline:=0; M1:=Mov(C,nd1,E); M2:=Mov(C,nd2,E); MACD:=M1-M2; MACDmov:=Mov(MACD,nmov,E); MACD; MACDmov; zeroline;
Filter: colB=Cross(MACD(),0)
Is there anything wrong on above code? Does anyone can help me? Thanks in advance for any suggestions..
|
|
|
|
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)
|
Code:nd1:=5;nd2:=35;nmov:=5;zeroline:=0;{You don't need to define this value, Metastock knows what 0 means}M1:=Mov(C,nd1,E);M2:=Mov(C,nd2,E);MACD:=M1-M2;MACDmov:=Mov(MACD,nmov,E);{in an exploration you don't need to state the following variable names}MACD;MACDmov;zeroline;{be careful of the placement of the last variable name in your indicator, If you use the Fml() function they default to the default settings in your inputs and give the value of the last named variable, in this case 0}{Cross(MACD,0) would be the last line of code if you want to know when M1 crosses above M2} {Cross(MACDmov,0) would be the last line of code if you want to know when the signal line crosses 0}
Filter: colB=Cross(MACD(),0) {by using Macd() you are going back to the default MACD setting in Metastock}
since you are trying to get a binary signal +1,0 as the end result , you can use the If() statement to also get the reverse crossing signal, so your end result +1,0,-1 would be the final outcomeand then in your filter section colB<>0 so only the crosses would show
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
MACD (5,35,5) plus crossing zero line for the explorer function
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.