Quotations export
Hi folks,
The main job of the MetaTrader terminal is retrieving the price quotations from the broker server and plot then on the chart. The price quotations include these data: BID price, ASK price, HIGH price, LOW price and Time.
This quotations enables you analyze the market and to use your trading strategies then to make your trading decisions. In brief the price quotations are almost everything you need for your forex live.
MetaTrader terminal enables you to export these quotations at the real-time by using the DDE technology.
DDE stands for Dynamic Data Exchange. DDE protocol enables two running applications to share the same data. The program who sends the data called "DDE server", and the program who captures the data from server called "DDE client". In our case the DDE server is MetaTrader terminal itself and the client is the program you write in any programming language (The program shipped with MetaTrader wrote in Excel).
How do the DDE servers work?
The DDE servers (Including MetaTrader) working with a very simple protocol.
The client sends a set of commands to the server in a proper format and the server returns the asked data to the client.
Each data item that a server application can provide has a unique identifier consisting of three parts, a DDE Application Name, a DDE Topic, and a DDE Item Name.
The DDE Application Name is almost always the executable filename for the server application (without the .EXE extension) in our case MT4 is the server name.
The DDE Topic typically identifies the category of data in the server application and each data item that a server can provide has a unique DDE Item Name. Thus, the Application Name, Topic, and Item Name identify the exact source of the data in a server application that is to be linked.
This is an example of a DDE request which MetaTrader can understand:
MT4|BID!EURUSD
In the above request we are asking MT4 to send us the BID price of the EURUSD currency pair.
The request starts with the server name (MT4), and then followed by the DDE topic (BID in our example).
MetaTrader DDE server understands these topics:
| Topic | Description |
| BID | Bid price. |
| ASK | Ask price. |
| HIGH | High price. |
| LOW | Low price. |
| TIME | The time. |
| QUOTE | The full quote. |
Between the server name and the DDE topic we put "|" symbol.
Then server name and the DDE topic followed by the DDE item (EURUSD), the DDE item is the currency pair we want to get the quote for it.
Between the DDE topic and DDE item we put "!" symbol.
In the Excel sample shipped with MetaTrader (DDE-Sample.xls file which you will find it in the path you installed MetaTrader in).
You will find these requests:
MT4|BID!USDCHF
MT4|ASK!USDCHF
MT4|HIGH!USDCHF
MT4|LOW!USDCHF
MT4|TIME!USDCHF
MT4|QUOTE!USDCHF
MT4|BID!GBPUSD
MT4|ASK!GBPUSD
MT4|HIGH!GBPUSD
MT4|LOW!GBPUSD
MT4|TIME!GBPUSD
MT4|QUOTE!GBPUSD
MT4|BID!USDJPY
MT4|ASK!USDJPY
MT4|HIGH!USDJPY
MT4|LOW!USDJPY
MT4|TIME!USDJPY
MT4|QUOTE!USDJPY
MT4|BID!EURUSD
MT4|ASK!EURUSD
MT4|HIGH!EURUSD
MT4|LOW!EURUSD
MT4|TIME!EURUSD
MT4|QUOTE!EURUSD
And this is the result:
| Symbol | Bid | Ask | High | Low | Time | Full |
| USDCHF | 1.2470 | 1.2475 | 1.2538 | 1.2462 | 2005/06/06 17:00 | 2005/06/06 17:00 1.2470 1.2475 |
| GBPUSD | 1.8194 | 1.8198 | 1.8216 | 1.8125 | 2005/06/06 17:00 | 2005/06/06 17:00 1.8194 1.8198 |
| USDJPY | 106.74 | 106.78 | 107.84 | 106.69 | 2005/06/06 17:00 | 2005/06/06 17:00 106.74 106.78 |
| EURUSD | 1.2281 | 1.2285 | 1.2293 | 1.2218 | 2005/06/06 17:00 | 2005/06/06 17:00 1.2281 1.2285 |
Enabling the DDE server:
The DDE client will not be able to work if there is no server running. So you have to execute MetaTrader before starting your client or you'll get a message like figure 1.
Running of MetaTrader is not enough to make the DDE server on, that's because -by default- the DDE server of MetaTrader is disabled. To enable the DDE server go to Tools menu and choose Options (or hit CTRL+O hotkeys). That will bring the Options window (Figure 2), choose server tab then check the option "Enable DDE server".
