Need help developing a simple EMA crossover EA. Any samples or useful resources?

Hello guys and girls.

I am a programmer but I never developed EAs. I would like to make a simple EA that enters a trade when EMA crossover happens and exits a trade when crossover happens again (in the opposite direction). Can someone help me?

Thanks in advance!

Here you have a free EMA Cross EA. You can look at the source code and suit your needs.
EMA Cross EA. Exponential Moving Average Expert Advisor. Free Forex System.

This is what I need. For example, I would like to use 3 EMAs:

5 EMA
8 EMA
15 EMA

The EA must enter a trade when 5 EMA crosses the 15 EMA and exit a trade when 5 EMA crosses the 8 EMA. Of course, I would also like to be able to set a S/L and T/P.

Dude, you can easily modify the Ea i posted. You only need to add a new EMA varible an change 10-15 lines of code at most.
5 is ema_fast, 15 is ema_slow. Create a variable called ema_slow2. This would be 8.
The function CalculaSignal() is where the signals open/close orders are generated. Copy the code in a new ffunction called CalculaSignal2() and replace ema_slow for ema_slow2. This new function will be used to generate the close signal.
Finally replace the CalculaSignal() call for CalculaSignal2() at the end of the robot() function, below the following comments:
ORDERS>0 AND DIRECTION=1 AND USE_TP_SL=1 and ORDERS>0 AND DIRECTION=2 AND USE_TP_SL=0.

1 Like

I had some free time so I did it. The variables are like I said in my previous post but in the end I only needed to change 3 lines of code. I have no tested it.

3EMA Cross EA.mq4.zip (7.03 KB)

I don’t think raw text editing is the best way to build EAs… With a graphical builder you don’t have to learn coding, you build them faster and you get a better picture of the whole system. I have been using FxDreema and I highly recommend it.

This doesnt work

I downloaded your link and used the EA… It triggers when ema_fast crosses ema_slow, but it doesnt close the position when ema_fast crosses ema_slow2.

any idea where to change the code for it? and maybe how to disable the TP/SL pips parameters so it only relies on the emas crossing for trigger and close trade. cheers