Discussing the article: "Websockets for MetaTrader 5: Asynchronous client connections with the Windows API"
Hello, I also think it is an excellent article.
I am developing an ea that uses multiple indicators. Initially I chose to functionalize the indicator calculations so they could be used in an indicator plot as well as in the EA. Upon testing in the strategy tester, I have found the Bars function returns a different value between the indicator running in visual mode and the value determined by the EA. Do you know how to report this and other bugs I have found in MLQ5 to the developers?
The simple solution was to use iCustom which I previously used in MQL4. However, the MQL5 version only allows CopyBuffer on the first indicator plot and many of my inidicators have multiple buffers plotted.
the solutions I can think of are to use your WebSockets to communicate between multiple indicators and the EA, named pipes to do the same, or separate the indicators into single buffer plots which will involve significant increasing processing due to the multiplicty of identical calculations as well as a nightmare trying to keep a dozen or more of indicators synchronized to insure accurate calculations.
As WebSockets is asynch what are the implications of the ea getting dozens of data streams from the indicators nearly simultaneously? Can it keep up or would there be overflows?
Any suggestions will be muchly appreciated.
Thank you for your response
CapeCoddah
Hello, I also think it is an excellent article.
I am developing an ea that uses multiple indicators. Initially I chose to functionalize the indicator calculations so they could be used in an indicator plot as well as in the EA. Upon testing in the strategy tester, I have found the Bars function returns a different value between the indicator running in visual mode and the value determined by the EA. Do you know how to report this and other bugs I have found in MLQ5 to the developers?
The simple solution was to use iCustom which I previously used in MQL4. However, the MQL5 version only allows CopyBuffer on the first indicator plot and many of my inidicators have multiple buffers plotted.
the solutions I can think of are to use your WebSockets to communicate between multiple indicators and the EA, named pipes to do the same, or separate the indicators into single buffer plots which will involve significant increasing processing due to the multiplicty of identical calculations as well as a nightmare trying to keep a dozen or more of indicators synchronized to insure accurate calculations.
As WebSockets is asynch what are the implications of the ea getting dozens of data streams from the indicators nearly simultaneously? Can it keep up or would there be overflows?
Any suggestions will be muchly appreciated.
Thank you for your response
CapeCoddah
Hi. You say:
The simple solution was to use iCustom which I previously used in MQL4. However, the MQL5 version only allows CopyBuffer on the first indicator plot and many of my inidicators have multiple buffers plotted.
That is not corect. You can copy any buffer you want. All three overloads of the CopyBuffer function allow you to copy any buffer you specify. Using the first version (shown below) as an example:int CopyBuffer( int indicator_handle, // indicator handle int buffer_num, // indicator buffer number int start_pos, // start position int count, // amount to copy double buffer[] // target array to copy );
The the second parameter 'buffer_num' allows you to specify which buffer to copy - starting at index 0 as first buffer, 1 for second buffer etc., allowing you to copy any buffer you desire from your custom indicator. An example of this is the built-in iMACD which has 2 buffers (0 - MAIN_LINE, 1 - SIGNAL_LINE). I would suggest you focus on iCustom indicator to solve your problem before trying WebSockets or Sockets of any kind for that matter. It is much simpler solution, which does not require any external libraries like C++ DLLs etc. Always try using the MQL5 language as much as possible, and avoid DLLs unless absolutely necessary. I develope in C, C++, C# and more, and I can tell you from experience that sticking to MQL5 (an extremely powerful language despite its limitations - as with any other language) is the best approch.
Let me know how you progress. If you face any issues with 'CopyBuffer' feel free to ask. If you're venturing to MQL5 from MQL4, some things are done differently, hence your MQL4 knowledge might not be directly transferrable. But keep going, MQL5 is much better, significantly more powerful and faster.
Good luck.
It might help to see some example code at:
Ryan L Johnson, 2025.04.29 19:52
This indicator calls 3 other subwindow indicators. All files go in your Indicators folder.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Check out the new article: Websockets for MetaTrader 5: Asynchronous client connections with the Windows API.
This article details the development of a custom dynamically linked library designed to facilitate asynchronous websocket client connections for MetaTrader programs.
The article, "WebSockets for MetaTrader 5: Using the Windows API", illustrated the utilization of the Windows API for the implementation of a websocket client within MetaTrader 5 applications. The implementation presented there was constrained by its synchronous operational mode.
In this article, we revisit the application of the Windows API to construct a websocket client for MetaTrader 5 programs, with the objective of achieving asynchronous client functionality. A practical methodology for realizing this objective involves the creation of a custom dynamically linked library (DLL) that exports functions suitable for integration with MetaTrader 5 applications.
Accordingly, this article will discuss the development process of the DLL and subsequently present a demonstration of its application through an MetaTrader 5 program example.
Author: Francis Dube