int start()
{
double ma3 , ma7 , ma14 ;
// int total;
// int ticket;
int Ans=0;
ma3=iMA(NULL,0,3,8,MODE_SMMA,PRICE_MEDIAN,0);
ma7=iMA(NULL,0,7,8,MODE_SMMA,PRICE_MEDIAN,0);
ma14=iMA(NULL,0,14,8,MODE_SMMA,PRICE_MEDIAN,0);
if( (Ask>ma3) > (ma7>ma14) )
{
Ans=1;
}
if( (Bid<ma3) < (ma7<ma14))
{
Ans=2;
}
else
{
Ans=0;
}
if(Ans==0)
{
closeall();
}
return(0);
}
void closeall()
{
int total =OrdersTotal();
for(int i=0;i<total;i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
int type = OrderType();
bool result = false;
switch(type)
{
case OP_BUY : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),3,Pink);
break;
case OP_SELL : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),3,Pink);
break;
case OP_BUYLIMIT : result = OrderDelete(OrderTicket());
break;
case OP_SELLLIMIT : result = OrderDelete(OrderTicket());
break;
case OP_BUYSTOP : result = OrderDelete(OrderTicket());
break;
case OP_SELLSTOP : result = OrderDelete(OrderTicket());
break;
}
}
}