![](/img/trans.png)
[英]How can I cancel a trade when another is open and keep the open trade for a given duration?
[英]how can I get last trade result?
我怎樣才能在 mql4 機器人中獲得最后的交易結果? 我的意思是代碼的一部分,我的不起作用。 這是代碼,我該怎么做?
int a = 0;
while(a == 0){
OrderSend(Symbol(),OP_BUY,0.01,price,5,0,(Ask+0.0002),0,0,0,Green);
a = 1;
}
//if(OrderSelect(OrdersTotal()-1, SELECT_BY_POS)==true){
// Print("Profit for the order 10 " + OrderProfit());
//}
//else{
// Print("OrderSelect returned the error of " + GetLastError());
//}
OrderSelect(OrderTicket(), SELECT_BY_POS);
Print("Profit for the order 10 " + OrderProfit());
OrderModify(OrderTicket(),OrderOpenPrice(),(Ask-0.0001),0,0,0);
if(OrderProfit()<0){
OrderSend(Symbol(),OP_SELL,0.01,price,5,0,0,0,0,0,Green);
}
else{
OrderSend(Symbol(),OP_BUY,0.01,price,5,0,0,0,0,0,Red);
}
至 select 交易池中最后未平倉或掛單:
OrderSelect(OrdersTotal()-1, SELECT_BY_POS);
如果要 select 最后關閉或取消的訂單:
OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS, MODE_HISTORY);
您可以在文檔OrderSelect()中獲取更多信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.