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

Notification

Icon
Error

Options
Go to last post Go to first unread
mmentors  
#1 Posted : Monday, March 13, 2006 4:18:13 PM(UTC)
mmentors

Rank: Member

Groups: Registered, Registered Users
Joined: 12/6/2005(UTC)
Posts: 10

I'm trying to create an exploration that will help me find stocks where the 50 MA has been flat for a period of time, say at least 10 bars, but price has moved quite a distance from the 50 MA. What I can't figure out is how to create the code for the "relatively flat 50 MA" part. Most indicators are tied to price, like volatility, so they don't work since I'm looking for price to have moved far from the MA, but the MA to still be flat. I think the best approach may be something like the 50 MA hasn't moved more than "x"% from the 50 MA 10 bars ago. But can't figure out how to write that. Anyone have any ideas pleas?
hayseed  
#2 Posted : Monday, March 13, 2006 8:32:12 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey mmentors.... coding is not my strong suit, yet, but until something better comes along perhaps roc of the ma might work....h ROC(Mov(C,50,S),10,%) < .25 AND ROC(Mov(C,50,S),10,%)> -.25
wabbit  
#3 Posted : Monday, March 13, 2006 10:42:09 PM(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)
mmentors, This logic should be relatively easy, following the guidance of the MS Users Manual? A flat MA, meaning the value now is the same (or nearly the same) as 10 bars ago, plus or minus some percentage difference? See if this works..... --8<-------------------------------- ind:=Mov(C,50,S); diff:=10 {percent}; lookback:=10; ind < ((100+diff)/100)*Ref(ind,-lookback) AND ind > ((100-diff)/100)*Ref(ind,-lookback); --8<-------------------------------- which, according to the MS Users Manual (and Hayseed) is the same as the ROC().... --8<-------------------------------- ind:=Mov(C,50,S); diff:=10 {percent}; lookback:=10; ROC(ind,lookback,%)<diff and ROC(ind,lookback,%)>-diff; --8<-------------------------------- It is truly amazing, the amount of information contained in that one guide! Hope this helps wabbit :D
StorkBite  
#4 Posted : Monday, March 13, 2006 11:56:57 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)
Here's yet another way: [code:1:370b60445e]{ user input } i1:=Input("EMA periods",1,252,10); i2:=Input("Lookback periods",0,100,1); i3:=Input("Percent cutoff",0.1,10,2); i4:=Input("Data Array (O=1 H=2 L=3 C=4 Typical=5)",1,5,5); i4:=If(i3=1,O,If(i3=2,H,If(i3=3,L,If(i3=4,C,Typical())))); { calculations } x:=mov(i4,i1,E); y:=ref(x,-i2); { plot } plot:=if(ABS(x-y)/x)*100 > i3,1,0); Plot[/code:1:370b60445e]
mmentors  
#5 Posted : Tuesday, March 14, 2006 12:08:22 AM(UTC)
mmentors

Rank: Member

Groups: Registered, Registered Users
Joined: 12/6/2005(UTC)
Posts: 10

Wow, what a great forum. 3 responses in a matter of a few hours. Amazing. Thanks to all 3 of you. What you posted does exactly what I was looking for. Interesting to see the different approaches too. I'm new to MetaStock and it helps me to see how you more experienced users code things. Thanks again.
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.