Help please

 

In an EA, I have SL=50.

But how write : SL=50 OR SL=Crossing of 2 MAs ?

Thanks for help.

 

Hi.

Place your stoploss when you place your order:

if(MA11>MA21 && MA12<MA22)

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Ask-stoploss*Point,0,0,Magic_number,0,Green);

}

if(MA11MA22)

{

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Bid+stoploss*Point,0,0,Magic_number,0,Red);

}

Just call the function before your entry rules:

MA_Exit();

This will close your orders if a cross happens.

void MA_Exit()

{

int total;

total = OrdersTotal();

double MA11 = iMA(NULL, 0, MA_period1, 0, 0, PRICE_CLOSE, 1);

double MA21 = iMA(NULL, 0, MA_period2, 0, 0, PRICE_CLOSE, 1);

double MA12 = iMA(NULL, 0, MA_period1, 0, 0, PRICE_CLOSE, 2);

double MA22 = iMA(NULL, 0, MA_period2, 0, 0, PRICE_CLOSE, 2);

for(int pos=total-1;pos>=0;pos--)

{

OrderSelect(pos,SELECT_BY_POS,MODE_TRADES);

if(OrderType()==OP_BUY)

{

OrderClose(OrderTicket(),OrderLots(),Bid,5,CLR_NONE);

}

if(OrderType()==OP_SELL)

{

OrderClose(OrderTicket(),OrderLots(),Ask,5,CLR_NONE);

}

}

}

 

Can You HELP Me

Hi Derikb,

Can you HELP me to create an EA ??

Best regards,

Paulinge

 
Paulinge:
Hi Derikb,

Can you HELP me to create an EA ??

Best regards,

Paulinge

Hi Paulinge,

If you have a profitable system, you can start a new thread and if people think the same way, I think they would help you.

Btw, I am from Indonesia too and a lot of Indonesian can help you to code an EA.