Заинтриговала одна вещь.В 2005 году Mark Brown (личный сайт:
www.markbrown.com) скомпилировал DLL библиотеку которая вызывает cmd окно Матлаба из программы Omega Research ProSuite 2000i. Но это устаревшая разработка позволяет работать в Матлаб 5 версий и ниже.
Возможно ли скомпилировать такую же библиотеку в Матлаб 2006b но которая будет вызывать cmd окно Матлаба из программы TradeStation 8.1(build 3228) следуя тому же пути что и Mark Brown?Необходимые файлы для компиляций этой DLL библиотеки (по Mark Brown) elkit32.h и elkitvc.lib имеются в папке Program программы TradeStation 8.1(build 3228).
Поделитесь пожалуйста мнением!
Ниже приводится издержки его работы и Screen shots с сайта
http://www.tsresearch.com
Tradestation - MatLab
TradeStation to MatLab link (TSML)
Copyrights Radin Yousefi - Mark Brown 2005
Contents
Description
Installing TSML Link
Using TSML Link
Function Reference
TSML_INIT,TSML_DONE
TSML_EVALSTRING
TSML_GETFMATRIX
TSML_PUTFMATRIX
Known problems
Compiling sources
Appendix
Description
Trade Station – MatLab link (TSML Link) is a software add-in that integrates Omega Research ProSuite 2000i and MATLAB. By connecting Omega Research ProSuite and MATLAB, you can access the numerical, computational, and graphical power of MATLAB from Omega Research ProSuite workspaces and EasyLanguage programming language. TSMLLink lets you exchange and synchronize data between the two environments. Its been fully tested using MatLab 6.0 and should work with 5.0 and above.
Installing TSML Link
1. Install Omega Research ProSuite and MATLAB before you install TSMLLink.
2. To install TSMLLink, just copy tsmllink.dll in %system%\system32 folder.
Using TSML Link
A DLL TSML Link function can be called from EasyLanguage in much the same way as it would be called from other programming languages once it is defined using DefineDLLFunc. A DLL function can be called within an expression or as a distinct statement if the return value is not used. To call a DLL function, the user must specify the function name and enclose all parameters within parenthesis. If multiple parameters are used, they must be separated by commas. See indicator sample (written in EasyLanguage) in appendix.
Function Reference
Link management functions
TSML_INIT Start MatLab engine
TSML_DONE Shutdown MatLab engine
Data management functions
TSML_EVALSTRING Evaluate command in MATLAB
TSML_PUTFMATRIX Create or overwrite MATLAB matrix with data from EasyLanguage array
TSML_GETFMATRIX Write contents of MATLAB matrix in EasyLanguage array
TSML_INIT, TSML_DONE
There is no need manually call this functions from EasyLanguage because MatLab engine will be automatically started with first call of data management functions.
TSML_EVALSTRING
Purpose Evaluate command in MATLAB
Syntax EasyLanguage
DefineDLLFunc: "tsmllink.dll", long, "TSML_EVALSTRING", lpstr;
lpstr EvalString - String to evaluate.
Functions returns a nonzero value if the MATLAB session is no longer running, and zero otherwise.
Example TSML_EVALSTRING ("b = b/2;plot (b)")
Divides the MATLAB variable b by 2 and plots it. Only the MATLAB variable b is modified. To update data in the EasyLanguage, use TSML_GETFMATRIX
TSML_GETFMATRIX
Purpose Write contents of MATLAB matrix in EasyLanguage array
Syntax EasyLanguage
DefineDLLFunc: "tsmllink.dll", long, "TSML_GETFMATRIX", lpst r, lpfloat, int, dword, dword;
lpstr MatrixName – Name of MATLAB matrix to create or overwrite.
"var_name" (in quotes) directly specifies the matrix name.
lpfloat ptrArray - address of EasyLanguage array
int nElemetCount - count of an elements in EasyLanguage array
dword dwStartAddress – Start address of an EasyLanguage array.
Use ArrayStartAddr EasyLanguage function to determine it.
dword dwSize – Size of an EasyLanguage array.
Use ArraySize EasyLanguage function to determine it.
Functions returns a nonzero value if the MATLAB session is no longer running, and zero otherwise.
Example Variables: lResult (0), MyStart (0), MySize (0);
Array: MyTestArrayOut [1](0);
Declaring variables
MyStart = ArrayStartAddr (MyTestArrayOut);
MySize = ArraySize (MyTestArrayOut);
Getting array address and size of array.
lResult = TSML_EVALSTRING("R=fix(10*rand(1,4))");
Creating matrix B in MATLAB and filling it with random generated values.
lResult = TSML_GETFMATRIX("R", &MyTestArrayOut[0], 2, MyStart, MySize);
Writing matrix B from MATLAB environment to EasyLanguage array
MyTestArrayOut
TSML_PUTFMATRIX
Purpose Create or overwrite MATLAB matrix with
Data from EasyLanguage array
Syntax DefineDLLFunc: "tsmllink.dll", long, "TSML_ PUTFMATRIX", lpstr, lpfloat, int, dword, dword;
lpstr MatrixName – Name of MATLAB matrix to create or overwrite.
"var_name" (in quotes) directly specifies the matrix name.
lpfloat ptrArray - address of EasyLanguage array.
int nElemetCount - count of an elements in EasyLanguage array.
dword dwStartAddress – Start address of an EasyLanguage array.
Use ArrayStartAddr EasyLanguage function to determine it.
dword dwSize – Size of an EasyLanguage array.
Use ArraySize EasyLanguage function to determine it.
Functions returns a nonzero value if the MATLAB session is no longer running, and zero otherwise.
Example Variables: lResult (0), MyStart (0), MySize (0);
Array: MyTestArrayIn [5](0);
Declaring variables
MyStart = ArrayStartAddr (MyTestArrayIn);
MySize = ArraySize (MyTestArrayIn);
Getting array address and size of array.
lResult = TSML_PUTFMATRIX("ELMATRIX", &MyTestArrayIn[0], 2, MyStart, MySize);
Writing EasyLanguage array MyTestArrayIn into matrix named
ELMATRIX in MATLAB.
Known problems
1. In this version of TSMLLink MatLab engine can’t automatically unload. User need manual close MatLab engine from Omega workspace after work finish.
2. If you using multidimensional arrays – EasyLanguage translate it to linear array, and you need use reshape function in MATLAB to change dimension after putting array to MATLAB workspace.
Compiling sources
To correct compile sources need to check following project settings in Microsoft
Visual C++:
1. C/C++ -> Preprocessor -> Additional include directories must indicate to directories that contains header files: engine.h and elkit32.h.
2. Link -> Input -> Additional library path must indicate to directories that contain library files: elkitvc.lib, libeng.lib, libmx.lib.
For practical use it is recommended to set up build option – Win32 Release.
Appendix
{*******************************************************************
Description : Example using TSML Link functions
Author Copyright Radin Yousefi - Mark Brown 2005
********************************************************************}
Variables: lResult(0), MyStartAddr(0), MyArraySize(0);
Array: MyTestArrayIn[3](0), MyTestArrayOut[3](0);
{* Declaring DLL functions *}
DefineDLLFunc: "tsmllink.dll",long,"TSML_EVALSTRING", lpstr;
DefineDLLFunc: "tsmllink.dll", long, "TSML_PUTFMATRIX", lpstr, lpfloat, int, dword, dword;
DefineDLLFunc: "tsmllink.dll", long, "TSML_GETFMATRIX", lpstr, lpfloat, int, dword, dword;
{* Getting address and size of an input array *}
MyStartAddr = ArrayStartAddr(MyTestArrayIn);
MyArraySize = ArraySize(MyTestArrayIn);
{* Put input array to MATLAB *}
lResult = TSML_PUTFMATRIX("INARRAY", &MyTestArrayIn[0], 4, MyStartAddr, MyArraySize);
{* Getting address and size of an output array *}
MyStartAddr = ArrayStartAddr(MyTestArrayOut);
MyArraySize = ArraySize(MyTestArrayOut);
{* Call TSML Link functions *}
lResult = TSML_EVALSTRING("INARRAY=fix(10*rand(1,4)); OUTARRAY=INARRAY;");
lResult = TSML_GETFMATRIX("OUTARRAY", &MyTestArrayOut[0], 4, MyStartAddr, MyArraySize);
{* Clear all variables in MATLAB if they no longer needed *}
lResult = TSML_EVALSTRING("clear");
{* Printing received results *}
Print("MyTestArrayOut[0] = ",MyTestArrayOut[0] );
Print("MyTestArrayOut[1] = ",MyTestArrayOut[1] );
Print("MyTestArrayOut[2] = ",MyTestArrayOut[2] );
Print("MyTestArrayOut[3] = ",MyTestArrayOut[3] );
{* Draw some information *}
plot1(lResult);
Final notes: Matlab link for TS. Instructions above. It works with Matlab 6 and not been tested with earlier versions but should work with 5 also. Also included a sophisticated data filter! So drop the dll in system32 directory in Win 2000 and make sure both ML and TS are on the same machine. The above code is for the indicator in TS: Place the am4.p file in your work directory in matlab before you start Matlab. Then start TS and run this indicator.
Additional files: tsmllink.dll and am4.p are included within this zip file(
http://www.markbrown.com/utility/matlab ... matlab.zip).
Copyrights Radin Yousefi - Mark Brown 2005
www.markbrown.com
[/img]