Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
how to write the code for Buylimit and selllimit @ a MA cross .
I am trying to use it for counter trend .... if anyone can modify the codes below for buylimit and selllimit orders.
//--------------------------------------------------------------------------------------//
void CheckOpen(){
bool Buy, Sell;
double MA1 =iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,1);
double MA2 =iMA(NULL,0,80,0,MODE_EMA,PRICE_CLOSE,1);
double MA3 =iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,2);
double MA4 =iMA(NULL,0,80,0,MODE_EMA,PRICE_CLOSE,2);
Sell = False;
if ( MA3 MA2 )
Sell = True;
Buy = False;
if ( MA3 > MA4 && MA1 < MA2 )
Buy = True;
double TP,SL;
//--------------------------------------------------------------------------------------//
if (Buy){
if(StopLoss==0){SL=0;}else{SL=Ask-StopLoss*Point;}
if(TakeProfit==0){TP=0;}else{TP=Ask+TakeProfit*Point;}
OrderSend(Symbol(),OP_BUY,lots,Ask,1,SL,TP,"PX4",IDT,0,LawnGreen);
}
if (Sell){
if(StopLoss==0){SL=0;}else{SL=Bid+StopLoss*Point;}
if(TakeProfit==0){TP=0;}else{TP=Bid-TakeProfit*Point;}
OrderSend(Symbol(),OP_SELL,lots,Bid,1,SL,TP,"PX4",IDT,0,HotPink);
}
}
//--------------------------------------------------------------------------------------//
thanks very much in advance ,
May God Bless you