Discussion of article "Orders, Positions, and Deals in MetaTrader 5" - page 5

 

Here's info from fxsaber on thisissue:https://www.mql5.com/ru/forum/366029/page3#comment_22547881 https://www.mql5.com/ru/forum/366029/page3#comment_22547881


@RashidUmarov

please ask developers to respond.

Библиотеки: TradesID
Библиотеки: TradesID
  • 2021.05.21
  • www.mql5.com
Статьи и техническая библиотека по автоматическому трейдингу: Библиотеки: TradesID
 

After the publication of the brakes of work with history, a lot of work was done by developers to create caches. The brakes have gone away.

Perhaps there is a mechanism of more economical caching. But it is certainly impossible to allow brakes.


ZY There are no comments on how to work with history the fastest way. At the moment 100% fast way is to call only HistorySelect everywhere.

HistorySelect(0, INT_MAX)
 
fxsaber:

After the publication of the brakes of work with history, a lot of work was done by developers to create caches. The brakes are gone.

Perhaps there is a mechanism of more economical caching. But it is certainly impossible to allow brakes.


ZY There are no comments on the fastest way to work with history. At the moment 100% fast way is to call only HistorySelect everywhere.

Why not
HistorySelect(t, INT_MAX)

where t is an arbitrary date that is not very long ago and does not change from call to call (a constant unified for the whole programme)?

 
mktr8591:
Why not

where t is an arbitrary date that is not very old and does not change from call to call (a constant, uniform for the whole programme)?

I'm not sure that this will make the cache smaller.

 
fxsaber:

I'm not sure if that would make the cache smaller.

Consumption is reduced. I used to prescribe it in the beginning.

bool HistorySelect2( const datetime From, const datetime To )
{
  static const datetime NewFrom = ::TimeCurrent() - 24 * 3600 & 30; // -Month.
  
  return(::HistorySelect(From ? From : NewFrom, To));
}

#define HistorySelect HistorySelect2

But I had to give up because of serious problems.

 
#define  PRINT(A) Print(#A + " = " + (string)(A))

void OnStart()
{
  PRINT(TerminalInfoInteger(TERMINAL_MEMORY_USED));
  
  if (HistorySelect(0, INT_MAX))
  {
    PRINT(HistoryDealsTotal());
    PRINT(HistoryOrdersTotal());
    
    PRINT(MQLInfoInteger(MQL_MEMORY_USED));
    PRINT(TerminalInfoInteger(TERMINAL_MEMORY_USED));
  }
}

Run result on Terminal with one M1 chart, 5000 bars, one symbol, no resources and no graphics.

TerminalInfoInteger(TERMINAL_MEMORY_USED) = 426
HistoryDealsTotal() = 134502
HistoryOrdersTotal() = 218740
MQLInfoInteger(MQL_MEMORY_USED) = 1
TerminalInfoInteger(TERMINAL_MEMORY_USED) = 789

It's a lot. 10 synchronous (OrderSend) EAs eats 4 gigs. Two options:

  1. Open a new account, transfer funds to it and continue trading on it. Unfortunately, it is not always possible.
  2. Combine all the bots into one through asynchrony(OrderSendAsync). This is a very hard variant of catching bugs in case of super-active trading.
In the second point, it is still necessary to write a manager (GUI and so on) of bots embedded in a single Expert Advisor.
 
fxsaber:



  1. Combine all bots into one through asynchrony(OrderSendAsync). Very heavy variant of catching bugs at super-active trading.

There is no other way. (unless, of course, you cut off the old history and redo the whole algorithm of working with history, but this is only if MQ do not return the old sorting).

 

Hi, folks!

It would be helpful that @MetaQuotes upgrade this article with Trade Classes (CAccountInfo, CSymbolInfo, COrderInfo, CHistoryOrderInfo, CPositionInfo, CDealInfoCTrade, CTerminalInfo). Develop EA under Object-Oriented paradigm could modify (and simplify) this operations of synchronize cache and to get data over symbols, orders, positions, deals, trades, etc.

Am I right?

Documentation on MQL5: Standard Library / Trade Classes / CAccountInfo
Documentation on MQL5: Standard Library / Trade Classes / CAccountInfo
  • www.mql5.com
CAccountInfo - Trade Classes - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

if you please how to calculate order commision with profit to be like this

" Profit += profit + swap + commision "