พี่ครับช่วยแก้โค้ตให้หน่อยครับมันไม่เปิด BUY อะครับมันเปิดแต่ SELL ช่วยแนะนำด้วยครับขอบคุณครับ
extern double lot =0.1;
extern double sl =999999;
extern double tp =5;
extern double trailing =0;
extern int MaxOrder =500;
extern int pip =20;
int start() {
if(OrdersTotal()<MaxOrder) {
double var1 = iMA(NULL,0,13,8,0,4,0);
double var2 = iMA(NULL,0,34,8,0,4,0);
if( var1 > var2) {
OrderSend(Symbol(),OP_BUYLIMIT,lot,Ask-Point*pip,3,Ask-Point*sl,Ask+Point*tp,"super1234567890",123,0,Green);
}
if(var1 < var2) {
OrderSend(Symbol(),OP_SELLLIMIT,lot,Bid+Point*pip,3,Bid+Point*sl,Bid-Point*tp,"super1234567890",123,0,Red);
}
trailingstop();
}
return(0) ;
}
void trailingstop() {
for(int count=0;count<OrdersTotal();count++)
{OrderSelect(count,SELECT_BY_POS,MODE_TRADES);
if(OrderType() == OP_BUY)
{if(trailing > 0){
if(Bid - OrderOpenPrice() > trailing*Point)
{if(OrderStopLoss()==0 || (Bid - OrderStopLoss()> trailing*Point))
{OrderModify(OrderTicket(), OrderOpenPrice(),Bid - trailing*Point, OrderTakeProfit(), 0, Blue); }
}
}
}
if(OrderType() == OP_SELL)
{ if(trailing > 0)
{if(OrderOpenPrice() - Ask > trailing*Point)
{
if(OrderStopLoss() == 0 || ( OrderStopLoss()-Ask > trailing*Point ) )
{OrderModify(OrderTicket(), OrderOpenPrice(),Ask + trailing*Point, OrderTakeProfit(), 0, Red); }
}
}
}
}
}