คือผมใส่เข้าไปแล้วมันเปิดแล้วปิดเลยครับ สำหรับ sell ครับ ส่วน buy มันไม่ยอมปิดให้เลยครับ ช่วยดูโค้ดให้หน่อยนะครับ อิอิ...จนปัญญาจริงๆ
int start()
{
double A, B, C, t, m, p, d, x, y, Lot;
int total;
int ticket;
//int ticket;
int SL = 100;
int TP = 15;
A = iClose(Symbol( ) ,PERIOD_M5,1); //5 minutes ago
B = iClose(Symbol( ) ,PERIOD_M5,0); //Present
t = Point*(-8); //SELL
m = Point*8; //BUY
d = B-A;
p = d/5;
Lot = 0.1;
total=OrdersTotal();
if(total<1)
{
if(p<0)
{
if(d<=t)
{
//SELL
ticket = OrderSend(Symbol(),OP_SELL,Lot,Bid,3,Ask+Point*SL,Bid-Point*TP,"RangerTOX",0,0,Red);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
//Reduce Loss
OrderSelect(ticket,SELECT_BY_POS);
C = OrderOpenPrice();
x = C+(Point*50);
if(B>C)
{
if(B>=x)
{
OrderClose(ticket,Lot,Bid,3,Red); //Close order
ticket = OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Bid-Point*70,Ask+Point*30,"RangerTOX",0,0,Green); //Open order "BUY"
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
}
}
}
}
if(p>0)
{
if(d>=m)
{
//BUY
ticket = OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Bid-Point*SL,Ask+Point*TP,"RangerTOX",0,0,Green);
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
//Reduce Loss
OrderSelect(ticket,SELECT_BY_POS);
C = OrderOpenPrice();
y = (C-(Point*50));
if(B<C)
{
if(B<=y)
{
OrderClose(ticket,Lot,Ask,3,Green); //Close order
ticket = OrderSend(Symbol(),OP_SELL,Lot,Bid,3,Ask-Point*70,Bid+Point*50,"RangerTOX",0,0,Red); //Open order "SELL"
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
}
}
}
}
}
}