Skip to content

MT4Account · Orders & Positions History — Overview

Live state snapshots + historical ledgers. Use this page to choose the correct data source for your UI, risk system, or analytics.

📁 What lives here


🧭 Plain English

  • opened_orders“What’s live right now?” — objects you see on the trade tab.
  • opened_orders_tickets“Did something open/close?” — fast change detection.
  • orders_history“What happened before?” — time‑ranged closed orders/deals ledger.

Rule of thumb: UI or risk needs details nowopened_orders(). Need just IDs to decide refresh → opened_orders_tickets(). Need past actionsorders_history().


Quick choose

If you need… Use Returns Key inputs
Full details of live positions & pending orders opened_orders OpenedOrdersData sort_mode?, deadline?, cancellation_event?
IDs only for open trading objects opened_orders_tickets OpenedOrdersTicketsData optional deadline, cancellation_event
Closed orders & deals over period orders_history OrdersHistoryData from, to, sort_mode, paging? (future)

❌ Cross‑refs & gotchas

  • UTC timestamps everywhere → convert once.
  • Server‑side sorting for opened_orders — enums drive ordering.
  • orders_history: mixed orders & deals — check which fields are set per row.
  • Filtering by symbol should be done on client side.
  • After reconnects: stream update may arrive first → pull a fresh snapshot.

🟢 Minimal snippets

# Count live objects
od = await acct.opened_orders()
print(len(od.order_infos))  # positions + pendings together
# Ticket set for quick diff
s = await acct.opened_orders_tickets()
all_tickets = set(s.position_tickets) | set(s.pending_order_tickets)
print(all_tickets)
# Last 24h closed records (depends on your history time fields)
from datetime import datetime, timedelta, timezone
end = datetime.now(timezone.utc)
start = end - timedelta(days=1)
h = await acct.orders_history(start, end)
print(len(h.orders_info))

See also