This example will show you how to implement the realtime ticks transfer from MetaTrader 5 client terminal to external server application.
The TCP protocol is used, it allows to transfer the data not only locally, but globally all over the Internet.
The Winsock2 library
(ws2_32.dll) is used for working with sockets. The direct calls of the library functions is impossible, because MQL5 doesnt allow to work with pointers and pass complex data structures as parameters of DLL functions. The library socket_mql5.dll, written in C++, is an intermediate wrapper, connecting the Expert Advisor and sockets library.
The interaction of MetaTrader 5 with external server application is presented at Fig. 1:
Figure 1. Interaction of MetaTrader 5 with external server application
The minimal set of the functions for one-way transfer (SocketOpen, SocketWrite, SocketClose) is implemented in socket_mql5.dll library.
An example of an Expert Advisor, connected to server and used to transfer the realtime tick data to external server application is presented at figure 2.
Figure 2. Export tick data from MetaTrader 5 client terminal to external server application
The archive contains:
Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/169
The indicator is based on the Elder's Impluse system.An Expert Advisor, based on Bollinger Bands ®
This Expert Advisor is based on Bollinger Bands. It uses trend-following strategy and Bollinger Bands indicator.