Các bác fix giúp em lỗi cái code move stop loss này với, chạy toàn báo lỗi error code 130.
//------------------------
void MoveStopLoss() // Move stoploss to free loss order point.
{
double Move_stop_loss_factor = 1;
double spread = MarketInfo(Symbol(), MODE_SPREAD);
if(OrdersTotal()>0)
for(int i = OrdersTotal() -1; i >=0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue; // Check Ticket number
if(!(OrderMagicNumber() == 1234 && OrderSymbol()==Symbol()))continue; // Check lenh dang mo
if(OrderType() == OP_BUY && (Bid - OrderOpenPrice()) >= Move_stop_loss_factor*(OrderOpenPrice()- OrderStopLoss()) )
{
bool res = OrderModify(OrderTicket(),OrderOpenPrice(), NormalizeDouble(OrderOpenPrice()+spread,Digits), OrderTakeProfit(), 0, Red);
if(!res){Print("Loi Modify Stoploss, error code = ", GetLastError()); return;}
}
if(OrderType() == OP_SELL && (OrderOpenPrice()- Ask) >= Move_stop_loss_factor*(OrderStopLoss()- OrderOpenPrice()) )
{
bool res = OrderModify(OrderTicket(),OrderClosePrice(), NormalizeDouble(OrderOpenPrice()-spread,Digits), OrderTakeProfit(), 0, Red);
if(!res) {Print("Loi Modify Stoploss, error code = ", GetLastError());return;}
}
} // end of loop
return;
}
//---------------------------------------
Các bác fix giúp em với, thanks các bác!
//------------------------
void MoveStopLoss() // Move stoploss to free loss order point.
{
double Move_stop_loss_factor = 1;
double spread = MarketInfo(Symbol(), MODE_SPREAD);
if(OrdersTotal()>0)
for(int i = OrdersTotal() -1; i >=0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue; // Check Ticket number
if(!(OrderMagicNumber() == 1234 && OrderSymbol()==Symbol()))continue; // Check lenh dang mo
if(OrderType() == OP_BUY && (Bid - OrderOpenPrice()) >= Move_stop_loss_factor*(OrderOpenPrice()- OrderStopLoss()) )
{
bool res = OrderModify(OrderTicket(),OrderOpenPrice(), NormalizeDouble(OrderOpenPrice()+spread,Digits), OrderTakeProfit(), 0, Red);
if(!res){Print("Loi Modify Stoploss, error code = ", GetLastError()); return;}
}
if(OrderType() == OP_SELL && (OrderOpenPrice()- Ask) >= Move_stop_loss_factor*(OrderStopLoss()- OrderOpenPrice()) )
{
bool res = OrderModify(OrderTicket(),OrderClosePrice(), NormalizeDouble(OrderOpenPrice()-spread,Digits), OrderTakeProfit(), 0, Red);
if(!res) {Print("Loi Modify Stoploss, error code = ", GetLastError());return;}
}
} // end of loop
return;
}
//---------------------------------------
Các bác fix giúp em với, thanks các bác!
Giới thiệu sách Trading hay
Nhật Ký Giao Dịch Thực Chiến của Phù Thủy Thị trường Tài Chính
Sách chia sẻ 05 tháng giao dịch thực tế trên thị trường tài chính, sử dụng Price Action và Mô hình Biểu đồ của Phù thủy trader Peter Brandt, người có gần 50 năm kinh nghiệm trading và đạt lợi nhuận bình quân 68% lợi nhuận mỗi năm
Bài viết liên quan