获取最近一张订单的订单编号、开仓价格

楼主  收藏   举报   帖子创建时间:  2019-05-05 11:13 回复:0 关注量:614

函数获取最近一张订单的订单编号、开仓价格。过滤条件:货币对、订单识别码、订单类型。

  1. double FindLastBuyPrice() {
  2. double l_ord_open_price_0;
  3. int l_ticket_8;
  4. double ld_unused_12 = 0;
  5. int l_ticket_20 = 0;
  6. for (int l_pos_24 = OrdersTotal() - 1; l_pos_24 >= 0; l_pos_24--) {
  7. OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES);
  8. if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
  9. if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber &&
  10. OrderType() == OP_BUY) {
  11. l_ticket_8 = OrderTicket();
  12. if (l_ticket_8 > l_ticket_20) {
  13. l_ord_open_price_0 = OrderOpenPrice();
  14. ld_unused_12 = l_ord_open_price_0;
  15. l_ticket_20 = l_ticket_8;
  16. }
  17. }
  18. }
  19. return (l_ord_open_price_0);
  20. }
打赏