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

Notification

Icon
Error

Options
Go to last post Go to first unread
Paradox  
#1 Posted : Sunday, January 20, 2008 12:57:47 AM(UTC)
Paradox

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 8/12/2007(UTC)
Posts: 6

Hi

I'm fairly new to MS still, as you'll soon findout out.

I'm trying to create a simple "Expert Advisor" which produces a buy signal when the EMA1 crosses above the EMA2 & a sell signal when it moves below.

1) What formula do I put in "Expert Symbol Editor" for the Enter Long & Exit Long (IE for Enter Long: previous EMA1<EMA2, current EMA1>EMA2).

2) Can you just have references to the EMA's currently showing on the chart or do you have to put the EMA number in the formula.

I've been looking around for the formula (through other similar posts) but can't find what I'm after.

Thanx

oztrader  
#2 Posted : Sunday, January 20, 2008 4:08:09 AM(UTC)
oztrader

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 7/12/2007(UTC)
Posts: 134
Location: Perth Western Australia

Hi Paradox,

"I'm trying to create a simple "Expert Advisor" which produces a buy signal when the EMA1 crosses above the EMA2 & a sell signal when it moves below."

From your rules set out above (i.e. second paragraph of your post) then consider the code below:-

Buy Signal (Enter Long or Buy) when Cross(EMA1,EMA2);
Sell Signal (Exit Long or Sell) when Cross(EMA2,EMA1);

The "Expert Function" does not of it's own accord reference any indicators on a chart.

If you refer to the MetaStock Manual that comes with the software then you will probably feel comfortable with substituting code for "EMA1" and "EMA2" to achieve your goal - but if not or you want confirmation then please post accordingly.

Cheers,
ozt

hayseed  
#3 Posted : Sunday, January 20, 2008 7:01:13 AM(UTC)
hayseed

Rank: Advanced Member

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

hey paradox..... somewhere on the forum patrick had posted many basic type expert systems.... lookin at how he coded those can be a big help for us new to meta, or at least was for me.....

in the system tester is a system, 'equis moving average',..... those rules would give you an idea of just what to put in the symbols section, just change out any opt's and rewrite to code to a manner you can easily relate to..... you didn't mention just what your planned exits would be , so this below is about as far as we can go......

you also didn't mention the trends and highlights section of the expert advisor, that code would be slightly different......

it takes some time but you'll eventually develope a coding style your comfortable with......h

buy symbol

//----------------------------

a:=Mov(C,10,E);
aa:=Mov(C,50,E);

Cross(a,aa)

//----------------------------

sell symbol

//--------------------------

a:=Mov(C,10,E);
aa:=Mov(C,50,E);

Cross(aa,a)

//-------------------------

exit long symbol

//-----------------------

you didn't mention long exit rules

//-----------------------

exit short symbol

//-----------------------

you didn't mention short exit rules

//-----------------------

henry1224  
#4 Posted : Sunday, January 20, 2008 10:41:36 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)

Hayseed, there are several ways to code systems. One must first decide what type of system he wants to develope?

Long only!

Short only!

Long and short, always in the market!

Long only but with the trend!

Short only but with the trend!

Long and short but only with the trend!

Paradox  
#5 Posted : Monday, April 28, 2008 2:59:47 AM(UTC)
Paradox

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 8/12/2007(UTC)
Posts: 6

Thanx Hayseed

Exactly what I'm after. Works like a charm.

To answer the LONG or SHORT question. I'm only after details for the Long side for now (Long Entry & Long Exit mentioned in the first question).

Thanx guys

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.