code เกห่าอาจจะไม่ครบเอาตัวไหมไปมันจะชื้อสลับกันนะตามที่เจ้าของเก่าเค้าโพสไวแต่ยังไงก็เจ๊งอยู่ดีนะ
extern int Lots=0.01;
static int memo=0;
int check (double v1 ,double v2)
{ static int lastway =0;
static int way =0;
if(v1 > v2)
{
way=1;
}
if(v1 < v2)
{
way=2;
}
if(way!= lastway)
{
lastway = way;
return (lastway);
}
return (0);
}
int start()
{
double var1 = iMA(NULL,0,12,0,1,0,0);
double var2 = iMA(NULL,0,26,0,1,0,0);
int kway = check(var1,var2);
int total =OrdersTotal();
int ticket;
double Lots=0.1;
if(total==0)
{
if(kway==1)
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"v1v2",0,0,Green);
memo=1;
}
if(kway==2)
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"v1v2",555,0,Red);
memo=2;
}
}
if(total==1)
{
if(kway==1 && memo==2)
{OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),3,Pink);
Sleep(2000);
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"v1v2",0,0,Green);
memo=1;
}
if(kway==2 && memo==1)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),3,Pink);
Sleep(2000);
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"v1v2",555,0,Red);
memo=2;
}
}
return(0);
}