extern double lots =0.1;
extern double sl =0;
extern double tp =0;
static int start=0;
int start() {
double var1 = iMA(NULL,0,1,0,1,0,0);
double var2 = iMA(NULL,0,12,0,1,0,0);
if(start==0)
{
if(var1>var2)
start=1;
if(var1<var2)
start=2;
return (0);
}
if(start==1 )
{
if(OrdersTotal()==1)
{ if(var1<var2)
{ OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),3,Pink);
Sleep(2000);
start=2;
return (0);
}
}
if(OrdersTotal()==0)
{ if(var1<var2)
{ OrderSend(Symbol(),OP_SELL,lots,Bid,3,0,0,"xxx",0,0,Red);
Sleep(2000);
start=2;
return (0);
}
}
}
if(start==2 )
{
if(OrdersTotal()==1)
{ if(var1>var2)
{ OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),3,Pink);
Sleep(2000);
start=1;
return (0);
}
}
if(OrdersTotal()==0)
{ if(var1>var2)
{ OrderSend(Symbol(),OP_BUY,lots,Ask,3,0,0,"xxx",0,0,Green);
Sleep(2000);
start=1;
return (0);
}
}
}
return(0) ;
}