//+------------------------------------------------------------------+
//| EA4Mf.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#define MAGICMA 20100102
#property copyright \"\"
#property link \"\"
extern int ordersNum = 1000;
extern double Lots = 0.01;
extern double Lots1 = 1;
extern int FastEMA = 5;
extern int SlowEMA = 34;
extern int SignalSMA = 5;
extern int timeSinceOpen = 600;
extern int timeClose = 120;
extern double TakeProfit = 50;
extern int stopL1 = 5;
extern int stopL2 = 7;
double timeLastOpen = 0;
double timeLastOpen1 = 0;
double lotx = 0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
lotx = Lots1;
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if(OrdersTotal()0){//多头市场,逢低做多
if(macd2macd1&&macd1>macd0){
if(CurTime() - timeLastOpen > timeSinceOpen){
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,\"\",MAGICMA,0,Red);//Ask+TakeProfit*Point
timeLastOpen = CurTime();
}
}
}
if(diff0=0&&macd2diff1 && diff1>0){
OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
if(CurTime() - timeLastOpen > timeSinceOpen){
OrderSend(Symbol(),OP_BUY,lotx,Ask,3,0,0,\"\",MAGICMA,0,Red);
timeLastOpen = CurTime();
lotx = 6 * lotx;
}
}
}
if(OrderType()==OP_BUY){
if(diff0=0 || diff0=stopL2*Point*TakeProfit){// && CurTime() - OrderOpenTime() > timeX //OrderOpenPrice()-Bid>=stopL*Point*TakeProfit
OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
/*if((CurTime() - timeLastOpen1 > timeSinceOpen1)&&(OrderOpenPrice()-Bid>=stopL2*Point*TakeProfit)){
OrderSend(Symbol(),OP_SELL,Lots1,Bid,3,0,0,\"\",MAGICMA,0,Red);//Bid-TakeProfit*Point
timeLastOpen1 = CurTime();
}*/
}
}
if(OrderType()==OP_SELL){
if(OrderOpenPrice()-Ask>=Point*TakeProfit||Ask-OrderOpenPrice()>=stopL2*Point*TakeProfit){//Ask-OrderOpenPrice()>=stopL*Point*TakeProfit
OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
/*if((CurTime() - timeLastOpen1 > timeSinceOpen1)&&(Ask-OrderOpenPrice()>=stopL2*Point*TakeProfit)){//CurTime() - timeLastOpen1 > timeSinceOpen1&&
OrderSend(Symbol(),OP_BUY,Lots1,Ask,3,0,0,\"\",MAGICMA,0,Red);//Ask+TakeProfit*Point
timeLastOpen1 = CurTime();
}*/
}
}
//}
}
return(0);
} |