extern double Lot=0.1;
extern int MegicNumber=1234;
int OnInit()
extern double A,B,C,D,E,F,G,H,I,J;
void OnTick()
{
if(CountOrder(OP_BUY)==0)
{
if( Hour()==A )
{
OrderSend(Symbol(),OP_BUY,Lot,Ask,3,0,0,"EX1",MegicNumber,0,Green);
}
}
if(CountOrder(OP_BUY)>0)
{
if( Hour()==B )
{
OrderSend(Symbol(),OP_BUY,Lot,Ask,3,0,0,"EX1",MegicNumber,0,Green);
}
if( Hour()==C )
{
OrderSend(Symbol(),OP_BUY,Lot,Ask,3,0,0,"EX1",MegicNumber,0,Green);
return 0;
}
if( Hour()==D )
{
OrderSend(Symbol(),OP_BUY,Lot,Ask,3,0,0,"EX1",MegicNumber,0,Green);
}
if( Hour()==E )
{
OrderSend(Symbol(),OP_BUY,Lot,Ask,3,0,0,"EX1",MegicNumber,0,Green);
}
if( Hour()==F )
{
OrderSend(Symbol(),OP_BUY,Lot,Ask,3,0,0,"EX1",MegicNumber,0,Green);
}
}
if(CountOrder(OP_SELL)==0)
{
if(Hour()==G)
{
OrderSend(Symbol(),OP_SELL,Lot,Bid,3,0,0,"EX1",MegicNumber,0,Green);
}
}
if(CountOrder(OP_SELL)>0)
{
if(Hour()==H)
{
OrderSend(Symbol(),OP_SELL,Lot,Bid,3,0,0,"EX1",MegicNumber,0,Green);
}
if(Hour()==I)
{
OrderSend(Symbol(),OP_SELL,Lot,Bid,3,0,0,"EX1",MegicNumber,0,Green);
}
if(Hour()==J)
{
OrderSend(Symbol(),OP_SELL,Lot,Bid,3,0,0,"EX1",MegicNumber,0,Green);
}
}
}
int CountOrder(int type)
{
int CntOrder=0;
for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==type&&OrderMagicNumber()==MegicNumber)
{
if(OrderSymbol()==Symbol())
{
CntOrder++;
}
}
}
return(CntOrder);
}