- Thread cover
- public/socialthumb.png
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 Bại Thị Trường Forex - Tư duy khác biệt và các kỹ thuật giao dịch của chuyên gia quản lý quỹ triệu đô
Sách chia sẻ kiến thức và kinh nghiệm trading từ một chuyên gia quản lý quỹ, cùng các kỹ thuật giao dịch giúp quỹ này đứng trong top nhiều năm
Bài viết liên quan