A new short example for using TWSLink with the actual version of MatLab (MatLab 2017a) is available.
The old example may not compiled in current MatLab script editor as the header declaration for TWSLink exported function was not compatible. This has been changed. So the new example comes with modified headers and a minimal example how to load TWSLink, connect, register and place a trade.
Please use the example as follows:
- Make sure TWSLink is installed ([ddownload id=”281″ style=”link” text=”TWSLink setup”])
- Download MatLab example and unzip in a folder of your choice.
- Open MatLab (tested with MatLab 2017a).
- In the script editor open twslink.m file from MatLab example folder.
- Run the script. You might get asked to add this folder to path or to change folder for execution. Select “Change Folder“.
[ddownload id=”413″ style=”link” text=”Download MatLab example”]
% load twslink dll
% uid of contract
% uid of order
% register EUR.USD CASH
uid = calllib('twslink', 'REGISTER_CONTRACT','EUR','CASH','USD','IDEALPRO','','','',0.0,'',0,0.0);
% connect to API (running TWS or gateway)
% SEL 25.000 EUR.USD CASH
% unload twslink