2025-09-22 09:09:20 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| OrdersGestor.mqh |
|
| | | //| Copyright 2025, Niquel Mendoza. |
|
| | | //| https://www.mql5.com/es/users/nique_372/news |
|
| | | //+------------------------------------------------------------------+
|
| | | #property copyright "Copyright 2025, Niquel Mendoza."
|
| | | #property link "https://www.mql5.com/es/users/nique_372/news"
|
| | | #property strict
|
| | |
|
| | |
|
2025-11-10 09:33:30 -05:00 | | | #ifndef MQLARTICLES_RM_ORDERGESTOR_MQH
|
| | | #define MQLARTICLES_RM_ORDERGESTOR_MQH
|
2025-09-22 09:09:20 -05:00 | | |
|
2025-11-23 10:36:16 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-01-28 17:12:28 -05:00 | | | #include "AccountStatus.mqh"
|
2025-09-22 09:09:20 -05:00 | | |
|
2025-11-23 10:36:16 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2025-09-22 09:09:20 -05:00 | | | #define CORDER_GESTOR_RESERVE_ARR 5
|
2025-11-23 10:36:16 -05:00 | | | // #define CACCOUNT_STATUS_ACTIVE_ON_ORDER_DELETE
|
| | |
|
2025-09-22 09:09:20 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | class COrderGestor : public CAccountGestor
|
| | | {
|
| | | private:
|
| | | int total_ordenes;
|
| | | ulong ordenes[];
|
| | | ulong ea_magic;
|
| | |
|
| | |
|
| | | public:
|
2026-01-31 19:44:40 -05:00 | | | COrderGestor();
|
2026-01-28 17:12:28 -05:00 | | | ~COrderGestor();
|
2025-09-22 09:09:20 -05:00 | | | //---
|
| | | void Initialize(ulong _ea_magic);
|
| | |
|
| | | //--- Add
|
| | | bool Add(ulong order_ticket);
|
| | |
|
| | | //--- Getters
|
| | | inline int OrdenesTotales() const { return total_ordenes; }
|
| | |
|
| | | //---
|
2025-11-23 08:04:37 -05:00 | | | void OnOrderDelete(const ROrder& order) override;
|
2025-09-22 09:09:20 -05:00 | | | };
|
| | |
|
2026-01-28 17:12:28 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-01-31 19:44:40 -05:00 | | | COrderGestor::COrderGestor()
|
| | | : total_ordenes(0), ea_magic(0)
|
2026-01-28 17:12:28 -05:00 | | | {
|
| | | ArrayResize(ordenes, 0, CORDER_GESTOR_RESERVE_ARR);
|
| | | account_status.RegisterEvent(&this, ACCOUNT_STATUS_REG_FLAG_ON_ORDER_DELETE);
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | COrderGestor::~COrderGestor(void)
|
| | | {
|
2026-01-31 19:44:40 -05:00 | | | if(account_status.IsActive())
|
2026-01-28 17:12:28 -05:00 | | | account_status.UnregisterEvent(&this, ACCOUNT_STATUS_REG_FLAG_ON_ORDER_DELETE);
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
2025-09-22 09:09:20 -05:00 | | | //+------------------------------------------------------------------+
|
| | | void COrderGestor::Initialize(ulong _ea_magic)
|
| | | {
|
| | | this.ea_magic = _ea_magic;
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
2026-01-28 17:12:28 -05:00 | | | void COrderGestor::OnOrderDelete(const ROrder &order)
|
2025-09-22 09:09:20 -05:00 | | | {
|
| | | if(order.order_magic != ea_magic)
|
| | | return;
|
| | |
|
| | | //---
|
| | | int pos = -1;
|
| | |
|
| | | //---
|
| | | for(int i = 0; i < total_ordenes; i++)
|
| | | {
|
| | | if(ordenes[i] == order.order_ticket)
|
| | | {
|
| | | pos = i;
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | //---
|
| | | if(pos == -1)
|
| | | return;
|
| | |
|
| | | //---
|
| | | total_ordenes--;
|
| | | ordenes[pos] = ordenes[total_ordenes];
|
| | |
|
| | | //---
|
| | | ArrayResize(ordenes, total_ordenes, CORDER_GESTOR_RESERVE_ARR);
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | bool COrderGestor::Add(ulong order_ticket)
|
| | | {
|
| | | if(order_ticket == INVALID_TICKET)
|
| | | return false;
|
| | |
|
| | | ArrayResize(ordenes, total_ordenes + 1, CORDER_GESTOR_RESERVE_ARR);
|
| | | ordenes[total_ordenes] = order_ticket;
|
| | | total_ordenes++;
|
| | | return true;
|
| | | }
|
2025-11-10 09:33:30 -05:00 | | | #endif // MQLARTICLES_RM_ORDERGESTOR_MQH
|
2025-09-22 09:09:20 -05:00 | | | //+------------------------------------------------------------------+
|