使用Python + MetaTrader5库 批量修改止盈止损

| 发表于 2025-7-27 03:00:34 | 显示全部楼层 |复制链接
  1. import MetaTrader5 as mt5
  2. if not mt5.initialize():
  3.     print("MT5初始化失败")
  4.     quit()
  5. positions = mt5.positions_get()
  6. for pos in positions:
  7.     new_sl = 1.2000
  8.     new_tp = 1.3000
  9.     request = {
  10.         "action": mt5.TRADE_ACTION_SLTP,
  11.         "position": pos.ticket,
  12.         "sl": new_sl,
  13.         "tp": new_tp,
  14.     }
  15.     result = mt5.order_send(request)
  16.     print(f"修改订单 {pos.ticket} 结果: {result}")
复制代码
举报

评论 使用道具

精彩评论2

xinhua123
DDD
| 发表于 2025-8-6 00:28:39 | 显示全部楼层
批量修改,谢谢
举报

点赞 评论 使用道具

gl370730
DD
| 发表于 2025-8-27 13:33:23 | 显示全部楼层
不断学习。不断充电
举报

点赞 评论 使用道具

发新帖
EA交易
您需要登录后才可以评论 登录 | 立即注册