EMA cross EA revision

 

Hello there! I uploaded an EA authored by Coders Guru. I like the way this EA works, but it has no stop loss. If it wouldn't be too much of a hassle, can a programmer please add a stop loss to this EA.

Thanks!

Files:
ema_6_12.mq4  8 kb
 
forexsolo wrote >>

Hello there! I uploaded an EA authored by Coders Guru. I like the way this EA works, but it has no stop loss. If it wouldn't be too much of a hassle, can a programmer please add a stop loss to this EA.

Thanks!

Hi forexsolo,

here is to try for you. pls.post some results

brg

Files:
 

Thanks for your quick response viennatrader. One other thing I forgot to add to my request was to change lot size to .10

I attempted to modify the EA via the metatrader editor, but once I changed it, the EA would not work. Can you tweak it a little bit more viennatrader by changing the lot size?

 
forexsolo wrote >>

Thanks for your quick response viennatrader. One other thing I forgot to add to my request was to change lot size to .10

I attempted to modify the EA via the metatrader editor, but once I changed it, the EA would not work. Can you tweak it a little bit more viennatrader by changing the lot size?

When you put the ea on the chart, you can change in the "input" tab, look for "Lots" there and change to the value u want.

If you want to change permanently, open the ema_6_12_sl.mq4 in Metaeditor,look for extern double Lots=1; and change to f.e. extern double Lots=0.1;

Press compile and finished :-)

 
viennatrader:

When you put the ea on the chart, you can change in the "input" tab, look for "Lots" there and change to the value u want.

If you want to change permanently, open the ema_6_12_sl.mq4 in Metaeditor,look for extern double Lots=1; and change to f.e. extern double Lots=0.1;

Press compile and finished :-)

Thanks viennatrader. I had no idea I had to press compile when making changes. All I was doing was pressing save. I learned something today. :-)

 

Instead of closing out with a limit or stop, how hard would it be to set this ea to close an order when it crosses again?

 
raytrader4x:

Instead of closing out with a limit or stop, how hard would it be to set this ea to close an order when it crosses again?

At first glance, there appears to be code to do this already, although the logic may be a bit dodgy if it's not doing it right.


...

   if (Crossed() == 1 )
BuyCondition = true;
...
if (Crossed ()== 2)
CloseBuyCondition = true;
...
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY) //<-- Long position is opened
{
if(UseClose)
{
if(CloseBuyCondition) //<-- Close the order and exit!
{
CloseOrder(OrderType()); return(0);
}
}
Reason: