Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

A restart silently disabled our trailing stop — and the crash fix is what hid it

说明与用途

重启时,交易机器人未能携带止损距离,导致跟踪止损永不触发,阶梯规则错误地关闭了仓位。修复方案从交易日志中检索原始距离并添加了安全计数器。

问题

When the bot restarts, it rebuilds positions without the stop‑loss distance, causing trailing stops never to arm and ladder rules to incorrectly cut positions.

结果

The bot now correctly arms trailing stops after 2R profit and no longer cuts recovered positions as dead weight; the silent failure is eliminated.

工作流

  • 1. Bot restarts and runs recovery code.
  • 2. Recovery code builds position objects from broker data, missing sl_dist field.
  • 3. Default sl_dist becomes 0, leading to divide‑by‑zero guard skipping trailing stop and ladder rule.
  • 4. Guard silently suppresses errors, no log output.
  • 5. Issue discovered when analyzing trade performance and noticing missing 2R gains.
  • 6. Fix implemented: lookup sl_dist from ledger and pass it during recovery.
  • 7. Additional safeguards added: safe defaults, hit counters, and audit logs.

证据

When our bot restarts, it takes back ownership of positions that are already open. To do that it rebuilds its internal picture of each position — and it forgot to carry over one number: the distance to the stop‑loss.

来源

The guard is the interesting bit. Someone — correctly — noticed that dividing by zero would crash the bot, so they wrote: if the distance is zero or less, skip the trailing stop.

来源

On restart the bot now looks the original stop distance up in its own trade ledger by ticket number and passes it in, along with the position size.

来源

  • 记录日期: 2026-10-09T22:55:50.315Z