Discussion of article "Library for easy and quick development of MetaTrader programs (part V): Classes and collection of trading events, sending events to the program"
Forum on trading, automated trading systems and testing trading strategies.
Less code, more rolling... writing an EA
fxsaber, 2019.03.12 21:46
This task can well be considered an initial test on the ability to write trading under MT5. So everyone can try their hand at it.
Forum on trading, automated trading systems and testing trading strategies
Less code, more rolling... writing an EA
fxsaber, 2019.03.12 21:40
Try here: ForexTimeFXTM-Demo01.
I wonder how the library handles a lot of trading nuances. So it's probably worth trying to pass at least the initial test
There are no trading classes in the library yet. At the moment the work with account history and active market state is coming to an end - tracking of netting account events will be published in the next article, then work with the account in MetaTrader 4, and then, after preparing classes for message output, work with trading classes will be described.
There are no trading classes in the library yet. At the moment the work with account history and active market state is coming to an end - tracking of netting account events will be published in the next article, then work with the account in MetaTrader 4, and then, after preparing classes for message output, work with trading classes will be described.
Got it. MT5 is so complex in this respect that I think we need a whole article that would describe in detail the trading subtleties arising on MT5 and how to take them into account.
Roger. MT5 is so complex in this respect that it probably needs a whole article describing in detail the trading subtleties that arise on MT5 and how to take them into account.
I am busy dealing with such situations. I hope I will be able to handle them all correctly.
Something else is interesting - on the basis of the described library user-case functions will be created for easy access to the data collected and stored in the library, for using trading classes, and accordingly - for simple and easy creation of programmes based on it.
Though already as it is - there is a possibility to use it, but at a lower level of access - by pointers to lists of collections, and from them - by pointers to any of their data. But this does not correspond to the "claims" stated at the very beginning about the ease of creating one's own programmes on the basis of the library. But this is just the beginning :)
library will automatically detect and work with both netting account and hedge type of accounts?
Yes. Already done. It will be published in the next article.
Yes. Already. The next article will be published.
New article Function library for easy and fast development of MetaTrader programs (part 5): trading event collection class, sending events to the program is published:
Author: Artyom Trishkin
Very powerful as a testing tool, thanks for sharing!
Hello Artyom, congratulations for the great job! Following the description in the text, it seems that function CHistoryCollection::OrderSearch(…) may have a break missing.
The for loop always complete all iterations from start-1 to 0, whether it finds the “lost order” or not.
Perhaps, it would be more efficient to include a break after finding the “lost order”:
ulong CHistoryCollection::OrderSearch(const int start,ENUM_ORDER_TYPE &order_type) { ulong order_ticket=0; for(int i=start-1;i>=0;i--) { ulong ticket=::HistoryOrderGetTicket(i); if(ticket==0) continue; ENUM_ORDER_TYPE type=(ENUM_ORDER_TYPE)::HistoryOrderGetInteger(ticket,ORDER_TYPE); if(this.IsPresentOrderInList(ticket,type)) continue; order_ticket=ticket; order_type=type; break; } return order_ticket; }
What do you think?

- www.mql5.com
Hello Artyom, congratulations for the great job! Following the description in the text, it seems that function CHistoryCollection::OrderSearch(…) may have a break missing.
The for loop always complete all iterations from start-1 to 0 , whether it finds the “lost order” or not.
Perhaps, it would be more efficient to include a break after finding the “lost order”:
...
What do you think?
There may be more than one lost order

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article Library for easy and quick development of MetaTrader programs (part V): Classes and collection of trading events, sending events to the program has been published:
In the previous articles, we started creating a large cross-platform library simplifying the development of programs for MetaTrader 5 and MetaTrader 4 platforms. In the fourth part, we tested tracking trading events on the account. In this article, we will develop trading event classes and place them to the event collections. From there, they will be sent to the base object of the Engine library and the control program chart.
Now we can compile the EA and launch it in the tester. When clicking the buttons, short two-line messages about occurring account events are displayed in the tester journal.
Entries from the EA event handler are not displayed in the journal since they work outside of the tester. If click on the EA buttons on a demo account, three lines are displayed in the terminal journal: two lines from the method for displaying short messages of the CEvent class and another one — from the EA's OnChartEvent() handler.
Below is a sample of displaying a message in the journal when placing and removing a pending order:
Author: Artyom Trishkin