Discussion of article "Library for easy and quick development of MetaTrader programs (part IV): Trading events"
Artyom Trishkin, thank you for your work, it feels like a powerful library. Please, if it is not difficult - can you briefly indicate what functionality you plan to cover (already covered and preparing for publication) except for working with orders/history. I just now started to write a similar library on the basis of a standard library, but I started from the side of such functionality as technical analysis tools. The idea is to write all the analysis tools used in classic TA and RA into the library and make them interoperable with indicator tools and others. CExpertSignal.
Perhaps, if your functionality covers what I have planned, then I should consider the option to continue-develop what you have already written.
Artyom Trishkin, thank you for your work, it feels like a powerful library. Please, if it is not difficult - can you briefly indicate what functionality you plan to cover (already covered and preparing for publication) except for working with orders/history. I just now started to write a similar library on the basis of a standard library, but I started from the side of such functionality as technical analysis tools. The idea is to write all the analysis tools used in classic TA and RA into the library and make them interoperable with indicator tools and others. CExpertSignal.
Perhaps if your functionality covers what I have planned, then I should consider the option to continue-develop what you have already written.
Everything that is currently described in the articles is only the beginning. Working with terminal order systems will be very simple. Giving to the programme on demand almost any data about any order, deal, position, event that has ever occurred, etc. That's the thing with order systems. Until the work and publication of articles on working with order systems of both terminals is completed and published, other functionality will not be published - all in order.
But in accordance with the structure laid down, work with price data, work with indicators, with graphical objects will be prepared and published, there will be a full-fledged graphical shell on the canvas, integrated into the structure of the library in accordance with the paradigm set initially. I.e., it will be possible to fully use only one library without the need to dock it with other libraries. As an example - getting data by clicking on the icon of an open position, an established order, getting data by clicking on a price bar, searching for some data in the existing collections, processing them, etc.
I plan to organise quick and convenient access in such a way that the user will not have to think about how to get the necessary data, but only to request and get it with one of the numerous functions that will be prepared, their full list will be compiled and published in the final articles of this series.
There are a lot of plans and a lot of developments. I am preparing the material. Including requests (of which there are none yet )
Everything that is now described in the articles is only the beginning. Working with the order systems of terminals will be very simple. Giving to the programme on demand almost any data about any order, deal, position, event that has ever occurred, etc. That's the thing with order systems. Until the work and publication of articles on working with order systems of both terminals is completed and published, other functionality will not be published - all in order.
But in accordance with the structure laid down, work with price data, work with indicators, with graphical objects will be prepared and published, there will be a full-fledged graphical shell on the canvas, integrated into the structure of the library in accordance with the paradigm set initially. I.e., it will be possible to fully use only one library without the need to dock it with other libraries. As an example - getting data by clicking on the icon of an open position, an established order, getting data by clicking on a price bar, searching for some data in the existing collections, processing them, etc.
I plan to organise quick and convenient access in such a way that the user will not have to think about how to get the required data, but only to request and get it with one of the numerous functions that will be prepared, their full list will be compiled and published in the final articles of this series.
There are a lot of plans and a lot of developments. I am preparing the material. Including requests (which are not yet available).
Very interesting. I have already seen two similar versions of the library here. Universal Expert Advisor and Cross-platform library. The first one is not quite cross-platform. And the second one has many drawbacks, in particular, it lacks many functions that would be cross-platform. For example, opening time or opening price of a position/order. You have to use macros of the MQL version yourself and write the code separately. But there are many interesting things there, in particular, I like the presence of several stops, trailing is very powerful and customisable. MM interesting options. This is a series of articles here from some Italian, I think you get the idea. Anyway, it's interesting to see what you get and it would be great if you utilise the experience of previous similar developments and take the best. Thanks.
Very interesting. I have seen two similar versions of the library here already. Universal Expert Advisor and Cross-platform Library. The first one is not really cross-platform. And the second one has many drawbacks, in particular, lack of many functions that would be cross-platform. For example, opening time or opening price of a position/order. You have to use macros of the MQL version yourself and write the code separately. But there are many interesting things there, in particular, I like the presence of several stops, trailing is very powerful and customisable. MM interesting options. This is a series of articles here from some Italian, I think you get the idea. Anyway, it's interesting to see what you get and it would be great if you utilise the experience of previous similar developments and take the best. Thank you.
Thanks for the opinion. But I am not able to read articles and search for what I need because I don't have time for that, but taking requests for future functionality, planning it and including it in the list for implementation is always welcome. There would be suggestions. So far I am doing what was originally planned for implementation.
Will this library work with exchange instruments on Moex?
In my opinion, you should not overload the library for working with orders with other functionality not related to money management, it is better to make separate libraries.
And yes, a detailed description of the library's manual is missing.
Will this library work with stock instruments on Moex?
In my opinion, you should not overload the library for working with orders with other functionality not related to money management, it is better to make separate libraries.
And yes, a detailed description of the library's manual is missing.
Tests will show. What will be noticed - will be fixed. There will be documentation for the library. Not right away.
Artem, about wishes - I think so - if you have any thoughts in terms of choosing which way to go in this or that decision, what is important and what to discard, etc...,
then you can publish their formulation in the form of a poll, etc., forum members will gladly give feedback on what they think about it.
But for someone to wish something specific, without knowing all the ideas of the project, it seems to me to be a miss, because you know, as usual - even an already ready and documented library everyone reads it differently and takes from it something of his own that is relevant to him at the moment.
So I wish you success and determination in your endeavour! :)
Read, compiled, running !
If I could rate 5 out of 5 stars
Top Artyom
Read, compiled, running !
If I could rate 5 out of 5 stars
Top Artyom
Artem, first of all. first of all. I would like to say thank you very much for the series of articles and the library. I have understood everything about OOP by reading your articles! Your articles really teach and help those who need it, they helped me. Your use of different algorithms in the same places where you could just repeat yourself is also very successful.
Now if I may get to the point: ::GetListByTime - in this method you select orders by time interval to pass the list to the calling programme, in Part 3 you write that:
"The desired property for search and comparison is set in the order properties depending on what time the list is sorted by: if by open time, then the property for search will be open time, if by close time, then the orders will be compared by their close time, etc."
But how? - In the method itself there is no possibility to change the sorting of the list of orders we are working with.
I understand, but I may be wrong, that whatever time intervals we pass (closing time, for example), the SearchGreatOrEqual() and SearchLessOrEqual() methods will search the sorted list by MT5 opening time and MT4 closing time? Since by default the initialisation of the order list in the constructor of the COrder collections class is mostly specified by the opening time or ticket of the order.
//+------------------------------------------------------------------+ //| Constructor| //+------------------------------------------------------------------+ CHistoryCollection::CHistoryCollection(void) : m_index_deal(0),m_delta_deal(0),m_index_order(0),m_delta_order(0),m_is_trade_event(false) { this.m_list_all_orders.Sort(#ifdef __MQL5__ SORT_BY_ORDER_TIME_OPEN #else SORT_BY_ORDER_TIME_CLOSE #endif ); this.m_list_all_orders.Clear(); this.m_list_all_orders.Type(COLLECTION_HISTORY_ID); }
//+------------------------------------------------------------------+ //| Constructor| //+------------------------------------------------------------------+ CMarketCollection::CMarketCollection(void) : m_is_trade_event(false),m_is_change_volume(false),m_change_volume_value(0) { this.m_list_all_orders.Sort(SORT_BY_ORDER_TIME_OPEN); this.m_list_all_orders.Clear(); this.m_list_all_orders.Type(COLLECTION_MARKET_ID); ::ZeroMemory(this.m_struct_prev_market); this.m_struct_prev_market.hash_sum=WRONG_VALUE; this.m_list_control.Clear(); this.m_list_control.Sort(); this.m_list_changed.Clear(); this.m_list_changed.Sort(); this.m_k_pow=(ulong)pow(10,6); }
So the above method (::GetListByTime) will work like this, always search by MT5 open time or MT4 close time.
//--- Compares COrder objects among themselves by all possible properties (to sort lists by the specified property of the COrder object
virtual int Compare(const CObject *node,const int mode=0) const;
you have written very narrowly(narrowly - does not mean that it iswrong) and it will use the sorting mode selected in the constructor of the order collections class from the standard MQL library when searching for orders according to the template. So: (in Part 3)
//+------------------------------------------------------------------+ //| Selects orders from the collection over time || //| in the range from begin_time, to end_time | //+------------------------------------------------------------------+ CArrayObj *CHistoryCollection::GetListByTime(const datetime begin_time=0,const datetime end_time=0, const ENUM_SELECT_BY_TIME select_time_mode=SELECT_BY_TIME_CLOSE) { ENUM_ORDER_PROP_INTEGER property=(select_time_mode==SELECT_BY_TIME_CLOSE ? ORDER_PROP_TIME_CLOSE : ORDER_PROP_TIME_OPEN); CArrayObj *list=new CArrayObj(); if(list==NULL) { ::Print(DFUN+TextByLanguage("Temporary list creation error","Error creating temporary list")); return NULL; } datetime begin=begin_time,end=(end_time==0 ? END_TIME : end_time); if(begin_time>end_time) begin=0; list.FreeMode(false); ListStorage.Add(list); //--- this.m_order_instance.SetProperty(property,begin); int index_begin=this.m_list_all_orders.SearchGreatOrEqual(&m_order_instance); if(index_begin==WRONG_VALUE) return list; this.m_order_instance.SetProperty(property,end); int index_end=this.m_list_all_orders.SearchLessOrEqual(&m_order_instance); if(index_end==WRONG_VALUE) return list; for(int i=index_begin; i<=index_end; i++) list.Add(this.m_list_all_orders.At(i)); return list; }
are not needed, because the standard library (methods SearchGreatOrEqual() and SearchLessOrEqual()) will still search by the sorting code passed in the constructor.
You can simply remove these lines highlighted in red and add conditional compilation lines to set the property for the object:
COrder m_order_instance; // Order object for searching by property
still the list can be sorted in only two ways or opening MT5 or closing MT4?
RIGHT?
P.S. this is needed just to understand the OOP logic!?!?

- www.mql5.com

- 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 IV): Trading events 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. We already have collections of historical orders and deals, market orders and positions, as well as the class for convenient selection and sorting of orders. In this part, we will continue the development of the base object and teach the Engine Library to track trading events on the account.
Let's launch the EA in the tester and try the buttons:
All is activated correctly, and the journal receives messages about occurring events.
Currently, all event messages in the tester journal are displayed in the CEngine::WorkWithHedgeCollections() method of the library base object, and we need the custom program to know the event codes in order to "understand" what happened on the account. This will allow us to form the program's respond logic depending on an event. To test the ability to achieve that, we will create two methods in the base object of the library. One method is to store the code of the last event, while another one is to decode this code consisting of a set of event flags.
Author: Artyom Trishkin