#define MagicNum 65
extern double TakeProfit = 490;
extern double Lots = 0.1;
extern double Osn = 10;
extern double Sig = 25;
extern double Sig2 = 48;
extern double Xs = 8;
extern double Xs2 = 8;
extern double Regul = 9;
extern double LMA1 = 0.00023;
extern double LMA2 = 0.0005;
double MA1;
double MA2;
double MA3;
double MA4;
double MA5;
double MA6;
double OOP;
int Or=0;
int ticket=0;
int US1=0;
int US2=0;
int S=0;
int B=0;
int Dol=0;
double MacdCurrent, MacdPrevious, SignalCurrent;
double SignalPrevious;
int start()
{
MA1=iMA(NULL,0,Osn,0,MODE_SMA,PRICE_CLOSE,0); //MA основной тренд
MA2=iMA(NULL,0,Sig,0,MODE_SMMA,PRICE_CLOSE,0); //MA поддерживающая
MA3=iMA(NULL,0,Xs,0,MODE_EMA,PRICE_CLOSE,0); // Фильтрующие
MA4=iMA(NULL,0,Xs2,0,MODE_SMA,PRICE_CLOSE,0);
MA5=iMA(NULL,0,Regul,0,MODE_SMA,PRICE_CLOSE,0);
MA6=iMA(NULL,0,Sig2,0,MODE_SMMA,PRICE_CLOSE,0); // регулирующая поддерживующую
MacdCurrent=iMACD(NULL,0,9,26,24,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,9,26,24,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,9,26,24,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,9,26,24,PRICE_CLOSE,MODE_SIGNAL,1);
if (Dol<1 && SignalPrevious>MacdPrevious && Ask>MA3-70*Point && Or<1 && US1<1 && Bid<MA4 && MA1<MA2 )
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,4,0,0,"Продаём",MagicNum,0,Blue);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("Продажа : ",OrderOpenPrice());
}
Or=Or+1;
US1=US1+1;
S=S+1;
OOP=OrderOpenPrice();
return;
}
//----------------------------------------------------Блок первого долива ---------------------------------------------------------
if (Dol<1 && Or<1 && US1<1 && SignalCurrent*5<MacdCurrent && SignalCurrent>LMA1 && SignalCurrent>MacdCurrent/7 && MacdCurrent>MacdPrevious )
{
ticket=OrderSend(Symbol(),OP_SELL,Lots*2,Bid,4,0,0,"Продаём",MagicNum,0,Gold);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("Продажа : ",OrderOpenPrice());
}
Or=Or+1;
US2=US2+1;
OOP=OrderOpenPrice();
return;
}
if (OrderMagicNumber()==MagicNum && Dol<1 && Or>0 && US2>0 && Ask>(OOP+(220*Point)) )
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Black);
Or=Or-1;
US2=US2-1;
return(0);
}
if (OrderMagicNumber()==MagicNum && Dol<1 && Or>0 && US2>0 && Ask<(OOP-(270*Point)) )
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Black);
Or=Or-1;
US2=US2-1;
return(0);
}
//---------------------------------------------- Блок второго долива ---------------------------------------------------------------
if (OrderMagicNumber()==MagicNum && S>0 && Dol<1 && Or>0 && US1>0 && SignalCurrent*5<MacdCurrent && SignalCurrent>LMA1 && SignalCurrent>MacdCurrent/7 && MacdCurrent>MacdPrevious )
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,LawnGreen);
Or=Or-1;
US1=US1-1;
S=S-1;
return(0);
}
if (OrderMagicNumber()==MagicNum && B>0 && Dol<1 && Or>0 && US1>0 && SignalCurrent*5<MacdCurrent && SignalCurrent>LMA1 && SignalCurrent>MacdCurrent/7 && MacdCurrent>MacdPrevious )
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,LawnGreen);
Or=Or-1;
US1=US1-1;
B=B-1;
return(0);
}
if (OrderMagicNumber()==MagicNum && S>0 && Ask<(OOP-(TakeProfit*Point)) && Or>0 && US1>0 && SignalCurrent<MacdCurrent )
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Gold);
Or=Or-1;
US1=US1-1;
S=S-1;
return(0);
}
if (OrderMagicNumber()==MagicNum && S>0 && Or>0 && US1>0 && Ask>(OOP+(250*Point)) && Bid>MA3 && MA2>MA6)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Black);
Or=Or-1;
US1=US1-1;
S=S-1;
return(0);
}
if (OrderMagicNumber()==MagicNum && SignalCurrent<SignalPrevious && MacdCurrent>SignalCurrent && Or>0 && US1>0 && S>0 && Ask<MA3 && MA3<MA6 && Ask<(OOP-(100*Point)))
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
Or=Or-1;
US1=US1-1;
S=S-1;
Dol=Dol+1;
return(0);
}
//------------------------------------------------------------
if (Dol>0 && Or<1 && US1<1 && MA3-20*Point<Ask)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots*2,Ask,4,0,0,"Покупаемс",MagicNum,0,Black);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("Покупаемс : ",OrderOpenPrice());
}
Or=Or+1;
US1=US1+1;
OOP=OrderOpenPrice();
return;
}
if (OrderMagicNumber()==MagicNum && Dol>0 && Bid<OOP-200*Point&& Or>0 && US1>0)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
Or=Or-1;
US1=US1-1;
Dol=Dol-1;
return(0);
}
if (OrderMagicNumber()==MagicNum && Dol>0 && Bid>OOP+200*Point && Or>0 && US1>0)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
Or=Or-1;
US1=US1-1;
Dol=Dol-1;
return(0);
}
//------------------------------------------------------------
if (Dol<1 && SignalCurrent/MacdCurrent>3 && MA3<MA1 && Or<1 && US1<1 && MA6-100*Point<MA2 && MA2<MA6 && MA5>MA1)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,4,0,0,"Покупаемс",MagicNum,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("Покупаемс : ",OrderOpenPrice());
}
Or=Or+1;
US1=US1+1;
B=B+1;
OOP=OrderOpenPrice();
return;
}
if (OrderMagicNumber()==MagicNum && B>0 && SignalCurrent>0 && MacdCurrent>0 && MacdCurrent<SignalCurrent && Bid>OOP+360*Point && MA2>MA6 && Or>0 && US1>0 && MA2+150*Point>MA1 && Bid>MA3)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Blue);
Or=Or-1;
US1=US1-1;
B=B-1;
return(0);
}
if (OrderMagicNumber()==MagicNum && B>0 && Bid<OOP-400*Point && Or>0 && US1>0 )
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Black);
Or=Or-1;
US1=US1-1;
B=B-1;
return(0);
}
return (0);
}