Discussions
»
Product and Service Development
»
Formula Assistance
»
MS Expert Advisor for Exponential Moving Average Crossover (Newb question)
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
|
|
|
|
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
|
|
|
|
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
//-----------------------
|
|
|
|
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!
|
|
|
|
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)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
MS Expert Advisor for Exponential Moving Average Crossover (Newb question)
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.