2026-08-14 21:09:42 -03:00 | | | //+------------------------------------------------------------------+
|
| | | //| IMarketEnvironment.mqh |
|
| | | //| Synthetic Test Harness for MetaTrader 5 |
|
2026-08-21 00:24:00 -03:00 | | | //| Institutional Architecture in MQL5 - Part 2 Series |
|
2026-08-14 21:09:42 -03:00 | | | //+------------------------------------------------------------------+
|
| | | #ifndef SYNTHETIC_TEST_HARNESS_IMARKET_ENVIRONMENT_MQH
|
| | | #define SYNTHETIC_TEST_HARNESS_IMARKET_ENVIRONMENT_MQH
|
| | |
|
| | | //+------------------------------------------------------------------+
|
2026-08-21 00:24:00 -03:00 | | | //| IMarketEnvironment: Outbound port abstracting the MT5 terminal. |
|
2026-08-14 21:09:42 -03:00 | | | //| |
|
2026-08-21 00:24:00 -03:00 | | | //| Decouples both trading strategy and risk management engines from |
|
| | | //| native global MT5 calls. Allows complete dependency injection. |
|
2026-08-14 21:09:42 -03:00 | | | //| |
|
| | | //| Concrete implementations: |
|
2026-08-21 00:24:00 -03:00 | | | //| - CSyntheticEngine (test: reads from injected ticks/delegates)|
|
| | | //| - CLiveEnvironment (prod: delegates to native MT5 API `::`) |
|
2026-08-14 21:09:42 -03:00 | | | //+------------------------------------------------------------------+
|
| | | interface IMarketEnvironment
|
| | | {
|
| | | //--- Price queries
|
| | | double GetBid(void);
|
| | | double GetAsk(void);
|
| | | double GetSpread(void);
|
| | |
|
| | | //--- Time abstraction
|
| | | datetime GetTimeCurrent(void);
|
| | |
|
2026-08-21 00:24:00 -03:00 | | | //--- Order execution: mirrors native OrderSend() contract
|
2026-08-20 22:00:35 -03:00 | | | bool OrderSend(MqlTradeRequest &request,
|
| | | MqlTradeResult &result);
|
| | |
|
2026-08-21 00:24:00 -03:00 | | | //--- Depth of Market (DOM) abstraction: mirrors native MarketBookGet()
|
2026-08-20 22:00:35 -03:00 | | | bool MarketBookGet(const string symbol,
|
| | | MqlBookInfo &book[]);
|
2026-08-14 21:09:42 -03:00 | | |
|
2026-08-21 00:24:00 -03:00 | | | //--- Generic Symbol Info Bridge
|
| | | double SymbolInfoDouble(const string symbol, const ENUM_SYMBOL_INFO_DOUBLE property);
|
| | | long SymbolInfoInteger(const string symbol, const ENUM_SYMBOL_INFO_INTEGER property);
|
| | |
|
| | | //--- Generic Account Info Bridge
|
| | | double AccountInfoDouble(const ENUM_ACCOUNT_INFO_DOUBLE property);
|
| | | long AccountInfoInteger(const ENUM_ACCOUNT_INFO_INTEGER property);
|
| | |
|
| | | //--- Margin Calculation Bridge
|
| | | bool OrderCalcMargin(const ENUM_ORDER_TYPE action,
|
| | | const string symbol,
|
| | | const double volume,
|
| | | const double price,
|
| | | double &margin);
|
| | |
|
| | | //--- Position Tracking Bridge
|
| | | int PositionsTotal(void);
|
| | | string PositionGetSymbol(const int index);
|
| | | long PositionGetInteger(const ENUM_POSITION_PROPERTY_INTEGER property);
|
| | | double PositionGetDouble(const ENUM_POSITION_PROPERTY_DOUBLE property);
|
| | |
|
| | | //--- Pending Order Tracking Bridge
|
| | | int OrdersTotal(void);
|
| | | ulong OrderGetTicket(const int index);
|
| | | long OrderGetInteger(const ulong ticket, const ENUM_ORDER_PROPERTY_INTEGER property);
|
| | | string OrderGetString(const ulong ticket, const ENUM_ORDER_PROPERTY_STRING property);
|
| | |
|
| | | //--- Deal History Bridge (for PnL accounting)
|
| | | bool HistorySelect(const datetime from_date, const datetime to_date);
|
| | | int HistoryDealsTotal(void);
|
| | | ulong HistoryDealGetTicket(const int index);
|
| | | long HistoryDealGetInteger(const ulong ticket, const ENUM_DEAL_PROPERTY_INTEGER property);
|
| | | double HistoryDealGetDouble(const ulong ticket, const ENUM_DEAL_PROPERTY_DOUBLE property);
|
| | | string HistoryDealGetString(const ulong ticket, const ENUM_DEAL_PROPERTY_STRING property);
|
| | | };
|
2026-08-14 21:09:42 -03:00 | | |
|
| | | #endif
|
2026-08-21 00:24:00 -03:00 | | | //+------------------------------------------------------------------+
|