Skip to content

History Order Info

CHistoryOrderInfo

Bases: COrderInfo

A lightweight Python wrapper that resembles the MQL5 Standard Library class CHistoryOrderInfo and provides convenient, read-only access to MetaTrader 5 history order properties.

This class acts like a cursor over a single selected historical order stored in self._order. The selected order can be supplied at construction time or later via select_order() / select_by_index().

Reference (MQL5)

Source code in strategytester5\trade_classes\HistoryOrderInfo.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class CHistoryOrderInfo(COrderInfo):
    """
        A lightweight Python wrapper that resembles the MQL5 Standard Library class
        `CHistoryOrderInfo` and provides convenient, read-only access to MetaTrader 5
        history order properties.

        This class acts like a cursor over a single selected historical order stored in
        `self._order`. The selected order can be supplied at construction time or later
        via `select_order()` / `select_by_index()`.

        [Reference (MQL5)](https://www.mql5.com/en/docs/standardlibrary/tradeclasses/chistoryorderinfo)
    """

    def __init__(self, order: TradeOrder):
        """
        Instantiates a CHistoryOrderInfo object.

        Args:
            order : A history order object returned by MetaTrader 5 Python history functions
            such as `mt5.history_orders_get()`.

        Notes:
            - If no order is selected, properties return `None` or `"N/A"`.
            - `time_setup`, `time_done`, and `time_expiration` are returned as timezone-aware
            UTC datetimes where possible.
            - This wrapper does not modify terminal state; it only reads history order data.

            Method groups mirror the MQL5 layout:<br>

            - Integer properties: TimeSetup, OrderType, State, TypeFilling, TypeTime, Magic, etc.
            - Double properties: VolumeInitial, VolumeCurrent, PriceOpen, StopLoss, TakeProfit, etc.
            - String properties: Symbol, Comment, ExternalId
            - Generic accessors: InfoInteger, InfoDouble, InfoString
            - Selection helpers: Ticket, SelectByIndex
        """

        super().__init__(order)

__init__(order)

Instantiates a CHistoryOrderInfo object.

Parameters:

Name Type Description Default
order

A history order object returned by MetaTrader 5 Python history functions

required
Notes
  • If no order is selected, properties return None or "N/A".
  • time_setup, time_done, and time_expiration are returned as timezone-aware UTC datetimes where possible.
  • This wrapper does not modify terminal state; it only reads history order data.

Method groups mirror the MQL5 layout:

  • Integer properties: TimeSetup, OrderType, State, TypeFilling, TypeTime, Magic, etc.
  • Double properties: VolumeInitial, VolumeCurrent, PriceOpen, StopLoss, TakeProfit, etc.
  • String properties: Symbol, Comment, ExternalId
  • Generic accessors: InfoInteger, InfoDouble, InfoString
  • Selection helpers: Ticket, SelectByIndex
Source code in strategytester5\trade_classes\HistoryOrderInfo.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def __init__(self, order: TradeOrder):
    """
    Instantiates a CHistoryOrderInfo object.

    Args:
        order : A history order object returned by MetaTrader 5 Python history functions
        such as `mt5.history_orders_get()`.

    Notes:
        - If no order is selected, properties return `None` or `"N/A"`.
        - `time_setup`, `time_done`, and `time_expiration` are returned as timezone-aware
        UTC datetimes where possible.
        - This wrapper does not modify terminal state; it only reads history order data.

        Method groups mirror the MQL5 layout:<br>

        - Integer properties: TimeSetup, OrderType, State, TypeFilling, TypeTime, Magic, etc.
        - Double properties: VolumeInitial, VolumeCurrent, PriceOpen, StopLoss, TakeProfit, etc.
        - String properties: Symbol, Comment, ExternalId
        - Generic accessors: InfoInteger, InfoDouble, InfoString
        - Selection helpers: Ticket, SelectByIndex
    """

    super().__init__(order)