Quote:
|
Originally Posted by rajatnaik
Hi,
i am writing a EA to calculate the cross price for EMA. How can i determine at what price the crossover has taken place???
Basially, how does one track if the 5 EMA has crossed over the 20 EMA...???
1.Ema period=5 with shift of -1
>>> 2.Ema period= 20 (no shift)
Open -Close-Open (reverse position)
Open- Close- New order...could be several orders inside a bar
If Requote, always a YES
|
For EA so: if price close so ma with 0 is crossing ma with 0. And one bar ago (+1 bar if it is close mode) ma is below or above the other ma with 1 bar as well.
If ma with other mode (not close price mode) so it is 1 and 2.
- (minus) 1 bar is the future.
"Future is not set". We have a thread with this "Future is not set" indicator (based on tartan's indicator for Goldwarrior EA).
There are a lot of EAs developed on this forum concerning MA crossing. As I remember Codersguru developed some EMA crossing EAs - look here
http://www.forex-tsd.com/ema-cross/
Besides there is thread with 3 EMA crossing EA
here.
You may take it from this examples (attached):
1. MA_ExpertProfit.mq4: it is the same EA but it will close the orders in s/l or t/p only.
2. MA_ExpertProfit_all.mq4: it will close the order on s/l or t/p, or on the other crossing signal. This EA should work on particular account only. Just change the line "int Account = 111111;" to your account number inside the code. For example your account is 1235463. So this line should be like this:
int Account = 1235463;
3. MA_ExpertProfit_noacc.mq4: it is the same with item # 2. But without any account and it may work in any account (i mean account in Metatrader).
And check this very good thread as well
Universal MA Cross EA