Skip to content

History Order Info

CHistoryOrderInfo

Bases: COrderInfo

Source code in strategytester5\trade_classes\HistoryOrderInfo.py
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
43
44
45
46
47
class CHistoryOrderInfo(COrderInfo):
    def __init__(self, order: TradeOrder, terminal: Union[OverLoadedMetaTrader5API|MetaTrader5]):

        """
        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()`.

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

        Parameters
        ----------
        order : Any, optional
            A history order object returned by MetaTrader 5 Python history functions
            such as `mt5.history_orders_get()`.
        terminal : Initialize native MetaTrader5 API or the simulated one from the StrategyTester instance

        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
        """

        super().__init__(order, terminal)

__init__(order, terminal)

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().

MQL5 Reference

Parameters

order : Any, optional A history order object returned by MetaTrader 5 Python history functions such as mt5.history_orders_get(). terminal : Initialize native MetaTrader5 API or the simulated one from the StrategyTester instance

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
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
43
44
45
46
47
def __init__(self, order: TradeOrder, terminal: Union[OverLoadedMetaTrader5API|MetaTrader5]):

    """
    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()`.

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

    Parameters
    ----------
    order : Any, optional
        A history order object returned by MetaTrader 5 Python history functions
        such as `mt5.history_orders_get()`.
    terminal : Initialize native MetaTrader5 API or the simulated one from the StrategyTester instance

    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
    """

    super().__init__(order, terminal)