Overview: Function Description
Description of function calling in TS MATLAB Link Dll
It's necessary to have a specialized library tsmatlablink.dll to work with the TS MATLAB Link Dll program. tsmatlablink.dll should be placed in the Windows (System32) system directory. For example, if you have system drive «С:\» and operating system Windows XP, then the path should be: «C:\WINDOWS\system32».
To work with TS MATLAB Link Dll in TradeStation environment the EasyLanguage function TS.MATLAB.LINK. should be used. This function uses tsmatlablink.dll to send commands from TradeStation to MATLAB and receive data back as Float (numeric) values. Set the code of EasyLanguage function:
if currentbar = 1 then begin
Value1 = TS.MATLAB.LINK("A = ["+ NumToStr(C,4)+"
]");
{create array A to
MATLAB and add value}
This function sends a text line that should contain data and any MATLAB command or a command only. The function returns the data that MATLAB has calculated in numeric format Float (numeric).
Example of usage.
First of all, you should call TS.MATLAB.LINK on the first bar and send any command to MATLAB. This may be, for example, the command which creates an «empty» array. It opens MATLAB Command Window. Here is an example of calling TS.MATLAB.LINK at the first bar in the EasyLanguage code:
if currentbar = 1 then begin
Value1 = TS.MATLAB.LINK("A = ["+ NumToStr(C,4)+"
]");
{create array A to
MATLAB and add value}
The function «TS.MATLAB.LINK» opens the MATLAB Command Window at the first bar and creates «A» array. In other words, calling this function will pass the string "A = ["+ NumToStr(C,4)+" ]" directly into the MATLAB Command Window. It is identical to the following command (let 28.66 is the Close price on the first bar): A=[28.66]
Let we want to calculate a moving average of fixed length in TradeStation using the MATLAB built-in formula. For calculation it in MATLAB it's necessary to:
1. create a MATLAB array ;
2. send a Close value on every bar to this array, in a way that the values are stored until the length holds;
3. displace the array to the right for new incoming data;
4. apply a MATLAB function mean to the array;
5. send obtained values back from MATLAB to TradStation.
|