jk01 发表于 2025-7-27 03:00:34

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

import MetaTrader5 as mt5

if not mt5.initialize():
    print("MT5初始化失败")
    quit()

positions = mt5.positions_get()
for pos in positions:
    new_sl = 1.2000
    new_tp = 1.3000
    request = {
      "action": mt5.TRADE_ACTION_SLTP,
      "position": pos.ticket,
      "sl": new_sl,
      "tp": new_tp,
    }
    result = mt5.order_send(request)
    print(f"修改订单 {pos.ticket} 结果: {result}")

xinhua123 发表于 2025-8-6 00:28:39

批量修改,谢谢

gl370730 发表于 2025-8-27 13:33:23

不断学习。不断充电
页: [1]
查看完整版本: 使用Python + MetaTrader5库 批量修改止盈止损