Communicating between EasyLanguage and C++

rp228

Newbie
Messages
1
Likes
0
I am trying to pass a pointer to an array from EasyLanguage code to a C++ dll. I tried printing the first element of the array and it returns different values. (it should return 5 but returns1084227584). I also tried checking the address of the array in C++ and it does not match the address in EL. Any suggestions?? Thanks.

Easy language code:
VAR: temp(0);
DefineDLLFunc: "....\TestProjCDLL.dll",LPINT,"MyTest",LPINT;

Array:TestArray[2](0);
TestArray[0]= 5;
TestArray[1]= 1;
temp =MyTest(&TestArray[0]);
print(date,temp);


C++ code:
int CTestProjCDLL::MyTest(int *arr)
{
return arr[0];
}
 
Are you using Tradestation 2000i or something newer ?

In the old TS 2000i software I find you have to skip alternate DWORDS of the array in the C/C++ code. That version of tradestation seems to pack it's arrays strangely.

I have no experience of newer versions but they might behave the same for backwards compatibility.

Remember also that arrays which look back at previous bar data are arranged in memory as circular buffers, so array element [i+1] does not always immediately follow array element in memory.
 
Last edited:
Top