【问题标题】:how can I get last trade result?我怎样才能得到最后的交易结果?
【发布时间】:2021-01-28 11:40:11
【问题描述】:

如何在 mql4 bot 中获得最后的交易结果? 我的意思是代码的一部分,我的不起作用。 这是代码,我该怎么做?

   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);
   }

【问题讨论】:

    标签: mql4 forex


    【解决方案1】:

    从交易池中选择最后一个未平仓或挂单:

    OrderSelect(OrdersTotal()-1, SELECT_BY_POS);
    

    如果您想选择最后关闭或取消的订单:

    OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS, MODE_HISTORY);
    

    您可以在文档OrderSelect()中获取更多信息

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多