รบกวนอีกรอบครับ T_T
ผมเขียนผิดตรงไหนเหรอครับ มันยังเปิดซ้ำอยู่เลย 555 ขอโทษที่ถามหลายรอบครับ
ไม่มีพื้นฐานเขียนโปรแกรมเท่าไหร่
int xxx=0;
int start()
{
double up=iCustom(NULL,0,"Hist",0,1);
double down=iCustom(NULL,0,"Hist",1,1);
if(xxx==0)
{
{ if(up >0)
{xxx=1;}
}
{ if(down >0)
{xxx=2;}
}
{ if(OrdersTotal()==0)
{ if (up>0 && xxx==1 )
{OrderSend(Symbol(),OP_BUY,0.2,Ask,3,Ask-Point*50,Ask+Point*150,"EX2",0,0,Green);
xxx=1;}
if (down > 0 && xxx==2)
{OrderSend(Symbol(),OP_SELL,0.2,Bid,3,Ask+Point*50,Ask-Point*150,"EX2",0,0,Red);
xxx=2;}
}
}
}
if (xxx!=0)
{ if (OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
{ if( (OrderClosePrice()!=OrderStopLoss())||(OrderClosePrice()!=OrderTakeProfit()) )
{ if(OrdersTotal()==0)
{ if (up>0 && xxx==1 )
{OrderSend(Symbol(),OP_BUY,0.2,Ask,3,Ask-Point*50,Ask+Point*150,"EX2",0,0,Green);
xxx=1;}
if (down > 0 && xxx==2)
{OrderSend(Symbol(),OP_SELL,0.2,Bid,3,Ask+Point*50,Ask-Point*150,"EX2",0,0,Red);
xxx=2;}
}
}
}
}
if(OrdersTotal()==1)
{ if(up>0&&xxx==2)
{OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_SELL)
{OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),3,Pink);
xxx=1;}
}
if(down>0&&xxx==1)
{OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUY)
{OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),3,Pink);
xxx=2;}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+