How to use AmiBroker with external DDE data source

Note: the most recent version of this document can be found at: http://www.amibroker.com/dde.html . Please check this page for updates.

WHAT IS DDE

DDE (Dynamic Data Exchange) is a Windows protocol used to allow applications to exchange data. For example, when you change a form in your database program or a data item in a spreadsheet program, they can be set up to also change these forms or items anywhere they occur in other programs you may use. DDE uses a client/server model in which the application requesting data is considered the client and the application providing data is considered the server.
Thousands of applications use DDE, including Microsoft's Excel, Word, Lotus 1-2-3, and Visual Basic.

For more information about DDE as communication mechanism in Windows please follow this link:
http://msdn.microsoft.com/library/en-us/winui/WinUI/WindowsUserInterface/DataExchange/DynamicDataExchange/AboutDynamicDataExchange.asp

DDE FOR TRADERS

What DDE offers for traders? Basically real time streaming quotes. There is NO BACKFILL via DDE. Many real-time data providers and brokerages provide ability to get real-time data by means of DDE. You should ask your brokerage/real-time data vendor if they offer DDE link. The DDE plugin now available for AmiBroker allows to link to (almost) any DDE source (server) supplying real-time quotes. This makes it attractive option for all data sources that do not have dedicated plugin.

WHEN NOT TO USE DDE PLUGIN

If you are using eSignal, IQFeed, Quote.com, and any other source that has dedicated plugin - you should use this dedicated plugin instead of DDE. This is so because dedicated plugins are ALWAYS better option (provide more features plus they are faster) than generic DDE.

DDE PLUGIN FEATURES SUMMARY

HISTORY

INSTRUCTIONS

To use DDE data plugin with AmiBroker you need to:

  1. (optional *) Download the latest version DDE plugin from http://www.amibroker.com/bin/DDE.dll and copy it to PLUGINS subfolder of AmiBroker directory.
    *Version 1.2.2 of DDE.DLL (Jun 7, 2007) is already included in AmiBroker 5.00 full setup
  2. Enable DDE in the 3rd party software you are using as DDE server (consult data vendor/brokerage software documentation for details on how to enable DDE)
  3. Run AmiBroker and create new database with "DDE universal data plugin" as a data source, following these steps:

The Plugin status indicator should change from Yellow "WAIT" to Green "OK" within a few seconds. If it does not turn to "OK" state it means that either:
a) server name and/or fields are not set up correctly
  or
b) DDE server (3rd party application) is not running or is not enabled

If indicator shows "OK" - then real time qutoes flow into AB. You can check it by displaying Window->Real time quote. Note: since there is no backfill you would need to wait for at least 3 bars of data to be collected before chart shows up.

CONFIGURING DDE PLUGIN TO WORK WITH YOUR VENDOR

Various data vendors come use different DDE connection strings, here a few typical exampels will be shown.

Most documentation of DDE uses Excel DDE syntax which looks as follows:=SERVER|TOPIC!ITEM

Server is a name of the DDE server such as WINROS, IQLINK, REUTER, CQGPC, MT, MTLink, etc.
Topic is the topic of DDE conversation. Depending on Data source topic may be just the ticker symbol (like in IQFeed), or the field name (like in winros).
Item is the item of DDE conversation. Depending on data source it can be field name (like in IQFeed) or ticker symbol (like in Winros).

So DDE connection string in two most common standards look as follows:

=WINROS|LAST!MSFT

=IQLINK|MSFT!LAST

Now DDE plugin configuration screen looks like this:



In the UPPER part of the dialog you can see "DDE Server" field. In this field you should enter SERVER part of DDE connection string (=SERVER|TOPIC!ITEM) without equation mark and without | character.

Below you can see 12 text entry boxes where you can define DDE topic and item for each data field your data source provides. Here you should enter TOPIC!ITEM pair of the DDE connection string (=SERVER|TOPIC!ITEM) with exlamation mark between DDE topic and DDE item.

As you can see in the picture above, DDE plugin allow you to use a few special strings, namely: {Ticker}, {Field}, {FieldSp}, {Server}, {Id} which are evaluated in run-time for each symbol separately allowing to construct dynamic DDE strings (depending on selected ticker for example) required by most data sources:

All other texts are carbon-copied, so if you write for example:

PREFIX_{Ticker }_SUFFIX!MYTEXT

it will evaluate to =SERVER|PREFIX_MSFT_SUFFIX!MYTEXT (provided that current symbol is MSFT)

Next to field definitions we can see what given definition will evaluate to (in Excel notation). This makes it easy to verify if definition is correct.

Sample evaluation uses always "MSFT" as a {Ticker}, and 34 as {id}.

If your data source does not provide all fields you can make given field empty. Note that for proper operation the "Last" price (the price of last trade) is required. If your data source does not provide "last" price (most of forex sources don't have "last") you can force DDE plugin to use "Bid" instead. For that you should make "Last" field blank and provide appropriate DDE topic!item pair in "Bid" field. Please also note that Topic!Item pairs should evaluate to unique values.

In the top part of the dialog you can see "Preset" combo-box.

As of now it allows to pre-set the fields using two generic schemes:
a) {Field}!{Ticker} - "last price" evaluates to =SERVER|Last!MSFT
b) {Ticker}!{Field} - "last price" evaluates to =SERVER|MSFT!Last

In the future "Preset" box will contain more presets for various DDE source that you submit.

A FEW EXAMPLES

Connection examples are shown on the web page: http://www.amibroker.com/dde.html

TEST PLATFORMS

DDE plugin has been tested and it is known to work properly on Windows XP (32 bit DDE) and Windows 9x (16 bit DDE).The following DDE servers are verified by us to work properly:

DDE plugin does NOT work with the following DDE servers:


All other DDE servers not listed above should work properly. Contact support at amibroker.com in case of problems.

HELP US TO HELP THE OTHERS:

In order to help the others to configure DDE plugin for their data vendor, once you succeded to link with your particular vendor please drop as a note with a screenshot of the CONFIGURE dialog and name of the source. This will be later included in this document as a reference how to use various data sources. Also working setups will be added to "presets" combo for easy one-click configuration.

NOTES ON DDE PLUGIN:

1. There is NO BACKFILL in DDE plugin. You can use however ASCII importer (this includes AmiQuote) to import historical data right into the database that you will update later in real time using DDE plugin.

2. Change, % change fields are NOT available (yet)

3. Time and Req fields are now ignored (this may change in the future)

4. The current system time is used to timestamp each tick.

5. When your source does not offer "LAST" price (like several Forex sources) you should make "Last" field EMPTY in the configuration dialog. This will tell the plugin to use "BID" field instead.

6. Plugin status (connected/disconnected) always initially comes up with "Wait" state (Yellow indicator). It means that no DDE conversation has been established. If at least ONE DDE conversation starts successfully it will turn to "OK" state (green indicator). If DDE server was not running at first attempt to connect, the plugin wil NOT attempt to reconnect automatically. Instead you should force reconnection manually (see point 7). The indicator may turn to "Disconnected" (red indicator) only in two cases:  
a) you were connected properly but DDE server (3rd party app) has been closed 
b) you selected "shutdown" from plugin status menu

7. You can reconnect at any time by selecting "reconnect" from plugin status menu.