Skip to content

Error #4754 - Order not found in calcCostByTicket #12

@seekersoftec

Description

@seekersoftec

Description

The EA logs a critical error calcCostByTicket error #4754 when attempting to process a specific ticket. This occurs on the XAUUSD on the M1 timeframe. The error indicates that OrderSelect or a history selection function failed because the ticket number provided does not exist in the current terminal context.

Error Log

2025.12.27 23:44:37.119 LRCUTB-v1.4 (XAUUSD,M1) calcCostByTicket error #4754 : Order not found (ticket=-83369947)

Environment

  • Platform: MetaTrader 5 (MT5)
  • Expert Advisor: LRCUTB-v1.4
  • Symbol: XAUUSD
  • Timeframe: M1
  • Error Code: 4754 (ERR_TRADE_ORDER_NOT_FOUND)

Suspected Root Causes

  1. Ticket Initialization: The log shows a negative ticket number (-83369947). In MT5, ticket numbers are ulong (unsigned), but a negative value suggests a casting error or an uninitialized variable being passed to the function.
  2. History Synchronization: The function calcCostByTicket may be trying to access a closed order before HistorySelect has been called or before the terminal has synchronized the trade history.
  3. Race Condition: The order may have been deleted or filled and moved to history between the time the ticket was captured and the time calcCostByTicket was executed.

Steps to Reproduce

  1. Attach LRCUTB-v1.4 to XAUUSD.
  2. Allow the EA to execute a trade or modify an existing position.
  3. Monitor the "Experts" tab for error #4754.

Proposed Fixes

  • Check the logic where the ticket variable is assigned to ensure it isn't being corrupted or treated as a signed integer.
  • Wrap the calcCostByTicket logic in a check to verify if the ticket exists using OrderSelect() or HistoryOrderSelect() before processing.
  • Ensure HistorySelect(0, TimeCurrent()) is called prior to searching for the ticket in the history pool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions