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

Notification

Icon
Error

Options
Go to last post Go to first unread
SixPak  
#1 Posted : Monday, April 4, 2005 5:54:10 AM(UTC)
SixPak

Rank: Newbie

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

Hello! I need help on how to write an Expert that has a 20 day moving average plotted along with a 15 day moving average of the first 20 day moving average. Can anybody help me with this? I'm able to plot the two moving averages but I'd like to use them in a system tester and expert and can't figure out how to do it. Dave
hayseed  
#2 Posted : Monday, April 4, 2005 10:00:46 AM(UTC)
hayseed

Rank: Advanced Member

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

hey sixpack..... metastock coding is not my forte, yet, but here might be a solution....... this indicator plots 1 when 20 is above the 15 and plots a -1 when 15 is above the 20.... change the 'E' to s for simple ma's
MASwitch:=If(Mov(( Mov(C, 20, E)),15,E)<Mov(C,20,E),1,If(Mov(( Mov(C, 20, E)),15,E)>Mov(C,20,E),-1,0)); If(BarsSince(MASwitch=1) <BarsSince(MASwitch=-1),1,-1)
for the expert bullish=(Mov(( Mov(C, 20, E)),15,E)<Mov(C,20,E)) bearish=(Mov(( Mov(C, 20, E)),15,E)>Mov(C,20,E))
---------------------------------------------------------- system tester
buy order=(Mov(( Mov(C, 20, E)),15,E)<Mov(C,20,E)) sell order=(Mov(( Mov(C, 20, E)),15,E)>Mov(C,20,E)) sell short order=(Mov(( Mov(C, 20, E)),15,E)>Mov(C,20,E)) buy to cover=(Mov(( Mov(C, 20, E)),15,E)<Mov(C,20,E)) here is 'intc' with my attempt at your indicator/expert........which could be completly wrong of course......h
hayseed  
#3 Posted : Monday, April 4, 2005 11:49:35 AM(UTC)
hayseed

Rank: Advanced Member

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

another thought here.... when its known exactly what is needed, purpose built code can be used..... however its often interesting to fiddle with the numbers without rewriting..... there, using the 'periods' referencing function in meta makes that investigation more enjoyable..... to see just copy, paste and fiddle below......h
Periods1:=Input("ema",1,252,20); Periods2:=Input("ema of period 1",2,1008,15); MASwitch:=If(Mov(( Mov(C, periods1, E)), periods2,E)<Mov(C, periods1,E),1,If(Mov(( Mov(C, periods1 , E)), periods2,E)>Mov(C,periods1,E),-1,0)); If(BarsSince(MASwitch=1) <BarsSince(MASwitch=-1),1,-1) -------------------------------------------------------------
hayseed  
#4 Posted : Monday, April 4, 2005 12:55:46 PM(UTC)
hayseed

Rank: Advanced Member

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

perhaps a better coder can take a look at what i provided.... it still appears redundant or excessive in length...... here might be a valid exploration for sixpack's indicator..... place in the filter section of explorer and it returns only the 'true' in column 1......h explorer filter
Mov(( Mov(C, 20, E)),15,E)<Mov(C,20,E) -----------------------------------------------
Patrick  
#5 Posted : Monday, April 4, 2005 4:02:30 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Thanks Hayseed, your formula is fine. My only comment here is that I would write the formula like this : for a buy let's say : MA1:=Mov(C,20,S); MA2:=Mov(MA1,15,S); Cross(MA1,MA2) It makes easier to adjust the values, and more often than not you want to use the cross function rather than > . Patrick
SixPak  
#6 Posted : Tuesday, April 5, 2005 2:26:22 AM(UTC)
SixPak

Rank: Newbie

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

hayseed wrote:
hey sixpack..... metastock coding is not my forte, yet, but here might be a solution....... this indicator plots 1 when 20 is above the 15 and plots a -1 when 15 is above the 20.... change the 'E' to s for simple ma's
MASwitch:=If(Mov(( Mov(C, 20, E)),15,E)<Mov(C,20,E),1,If(Mov(( Mov(C, 20, E)),15,E)>Mov(C,20,E),-1,0)); If(BarsSince(MASwitch=1) <BarsSince(MASwitch=-1),1,-1)
for the expert bullish=(Mov(( Mov(C, 20, E)),15,E)<Mov(C,20,E)) bearish=(Mov(( Mov(C, 20, E)),15,E)>Mov(C,20,E))
---------------------------------------------------------- system tester
buy order=(Mov(( Mov(C, 20, E)),15,E)<Mov(C,20,E)) sell order=(Mov(( Mov(C, 20, E)),15,E)>Mov(C,20,E)) sell short order=(Mov(( Mov(C, 20, E)),15,E)>Mov(C,20,E)) buy to cover=(Mov(( Mov(C, 20, E)),15,E)<Mov(C,20,E)) here is 'intc' with my attempt at your indicator/expert........which could be completly wrong of course......h
Well, if Metastock coding is not your forte, I like to see what you're really good at! :lol: I plugged the formulae in to the expert for the NDX and it works great. I'd like to use that same idea in the System Tester to see which periods work the best. Is that possible? Sorry for being so dumb at this......programming is not my forte. But, thanks so much for the help. You guys are great!
SixPak  
#7 Posted : Tuesday, April 5, 2005 3:34:58 AM(UTC)
SixPak

Rank: Newbie

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

Patrick wrote:
Thanks Hayseed, your formula is fine. My only comment here is that I would write the formula like this : for a buy let's say : MA1:=Mov(C,20,S); MA2:=Mov(MA1,15,S); Cross(MA1,MA2) It makes easier to adjust the values, and more often than not you want to use the cross function rather than > . Patrick
Thanks for the reply Patrick. I'm not sure what to do with those formulae. Do I enter that for "bullish" in an expert just like you have it there? Dave
SixPak  
#8 Posted : Tuesday, April 5, 2005 6:22:08 AM(UTC)
SixPak

Rank: Newbie

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

With your help (Hayseed), I managed to figure out what I needed to do to create the System Test I was looking for. Here's what I used as my "Buy" signal: (Mov(( Mov(C, opt1, E)),opt2,S)<Mov(C,opt1,E)) For the NDX index, the best results over 4 years of backtesting were a 33 day EMA (opt1) crossing its 25 day SMA (opt2). Thanks again for the help! Forums like this are indispensable! Dave
Users browsing this topic
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.