Skip to main content

Resolve HOLD vs execution timeout confusion

Summary​

Investigated why bot f7657e75-dbfb-4854-9af6-67f538c1362b appeared to HOLD despite all strategy checks being green.

Root cause findings​

  1. Strategy was often HOLDing because entry thresholds were not explicitly shown in monitor diagnostics.
  2. After strategy tuning, BUY/SELL signals did fire, but order execution failed at broker layer with cTrader timeout errors.
  3. A backend bug in order execution error handling allowed AppError paths to bypass the failed status update, leaving many bot_orders rows in pending even when execution had already failed.

Code changes​

  1. Preserved structured strategy check values (objects/booleans/arrays) in custom strategy normalization:
    • services/backend/src/lib/custom-strategy-runtime.ts
  2. Broadened check value type in shared backend and frontend types:
    • services/backend/src/lib/backtest-engine/types.ts
    • services/backend/src/lib/bot-tick-decisions-repo.ts
    • services/frontend/src/lib/api-client/index.ts
  3. Improved monitor check-value rendering and filtering for structured values:
    • services/frontend/src/routes/bots/MonitorPanel.tsx
  4. Updated bot-specific manual strategy source to emit explicit entry checks and clearer HOLD reasons:
    • services/backend/tmp_live_strategy_v7.ts
    • Added atLowerGrid / atUpperGrid checks
    • Added gap-in-pips diagnostics and tolerance support
    • Added nearest-edge disambiguation when both edges are within tolerance
  5. Fixed order failure handling so broker AppError paths still mark orders as failed:
    • services/backend/src/routes/exchange/exchange-execution.ts

Live data changes (DB)​

  1. Published manual strategy version 9 and then version 10 for bot f7657e75-dbfb-4854-9af6-67f538c1362b.
  2. Updated bot parameter triggerTolerancePips to 0.5.
  3. Backfilled recent stuck pending orders for this bot to failed where no exchange order id existed.

Deployments​

Backend deployed to both dev and production after each relevant code change.

  • Dev version IDs observed:
    • b92846ff-a50e-4929-aefb-97e81ad3e5b5
    • 7e9deb31-cf46-40c1-b6f2-4518faad824a
  • Prod version IDs observed:
    • 9fbf9f47-1d4d-48c0-82ec-cae41fed76f4
    • 29471f10-755e-410c-9467-a80e9c3b938a

Validation snapshot​

Recent decisions show BUY/SELL signals are being produced, but broker execution currently times out:

  • Decision/action example: BUY + error
  • Error example: Pepperstone/cTrader order failed: Timed out placing cTrader demo order for EURUSD after 15000ms

This confirms strategy gating is no longer the blocker; broker execution reliability is now the active blocker.