Libraries: CLiveTradeInfo - CHistoryTradeInfo

CLiveTradeInfo - CHistoryTradeInfo:

The library reconstructs a complete MQL4-style order model on top of the native MQL5 Position, Order, Deal, and History APIs. This design allows legacy MQL4 Expert Advisors to operate with minimal code changes while preserving MQL5.

CLiveTradeInfo - CHistoryTradeInfo

Author: Hans Alexander Nolawon Djurberg

Serious stress tests are needed.
fxsaber #:
Serious stress tests are needed.
It's tested with several opening/closing orders/positions, you can try the test demo file on your side.
It would be good to add all the Order functions.
Trade Functions - MQL4 Reference
Trade Functions - MQL4 Reference
  • docs.mql4.com
Trade Functions - MQL4 Reference
Hans Alexander Nolawon Djurberg #:
It's tested with several opening/closing orders/positions, you can try the test demo file on your side.
#include <MQL4TradeCompat_define.mqh> // https://www.mql5.com/en/forum/518160#comment_60549462

#define Bid SymbolInfoDouble(_Symbol, SYMBOL_BID)
#define Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK)

void OnStart()
{
  Print(AccountInfoString(ACCOUNT_SERVER));
  
  // https://docs.mql4.com/trading/ordersend
  Print(OrderSend(_Symbol, OP_BUY, 0.1, Ask, 0, 0, 0));
}


Result.

Trades  '': market buy 0.1 AUDCAD
Trades  '': deal #10662681920 buy 0.1 AUDCAD at 0.99357 done (based on order #10922861691)
Trades  '': accepted market buy 0.1 AUDCAD
Trades  '': order #10922861691 buy 0.1 / 0.1 AUDCAD at 0.99357 done in 38.948 ms
MetaQuotes-Demo
-1962040197
fxsaber #:
#include <MQL4TradeCompat_define.mqh> // https://www.mql5.com/en/forum/518160#comment_60549462 #define Bid SymbolInfoDouble(_Symbol, SYMBOL_BID) #define Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK) void OnStart() {   Print(AccountInfoString(ACCOUNT_SERVER));      // https://docs.mql4.com/trading/ordersend   Print(OrderSend(_Symbol, OP_BUY, 0.1, Ask, 0, 0, 0)); }

Seems there is something wrong on your side, I tested :

Alpari-MT5-Demo
388445700

result



fxsaber #:
It would be good to add all the Order functions.

The main purposes was the repository pool of trades (orders & positions) for both history/live. others can be developed by developers/users.

But thanks for the tip. i added it.

Hans Alexander Nolawon Djurberg #:

Seems there is something wrong on your side, I tested :

I specifically specified the name of the server where you can easily open a demo account for testing purposes.

The reason for the error is that not all tickets fit into the `int` format; you need to use `long`.
Hans Alexander Nolawon Djurberg #:

But thanks for the tip. i added it.

OrderPrint, OrderProfit, ....


fxsaber #:
I specifically specified the name of the server where you can easily open a demo account for testing purposes.

The reason for the error is that not all tickets fit into the `int` format; you need to use `long`.

you're right,i changed/updated it to ulong type.

But i tested on testing broker:

MetaQuotes-Demo
1821076608
The result is the same.
Hans Alexander Nolawon Djurberg #:

you're right,i changed/updated it to ulong type.

You can't use `ulong`, because `OrderSend` needs to be able to return -1.

But i tested on testing broker: The result is the same.


The log shows how large the numbers are.

Forum on trading, automated trading systems and testing trading strategies

Libraries: CLiveTradeInfo - CHistoryTradeInfo

fxsaber, 2026.10.13 08:05

Trades  '': order #10922861691 buy 0.1 / 0.1 AUDCAD at 0.99357 done in 38.948 ms


All in all, quite a few checks need to be performed to ensure everything is working correctly.

fxsaber #:
All in all, quite a few checks need to be performed to ensure everything is working correctly.
Everything is working correctly, just large number was not handled by 'int', is changed to 'long' now.