[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TS 4 DLL - FindAddress_Var



PureBytes Links

Trading Reference Links

I'm having trouble getting the TS Kit FindAddress_Var function to return the 
correct value of a variable. I have TS 4 build 23. My compiler is MS VC++ v 
1.52.  The intent of the following crude example is simply to copy the 
current Close into Z then call the dll and return a value from the variable Z 
based on the offset passed via X. Passing "&Z" to the dll always returns Z[0] 
or Z[1] every other call no matter what the value of X is.  Passing "&Z[1]" 
appears to work but of course I'm off by one day.

Can anyone shed some light on this for me and tell me what I'm doing wrong or 
help me better understand the concept of traversing through circular buffers 
in a dll? Why does passing &Z[1] seem to work but &Z does not?    

Thanks, 
Mike

{MaxBarsBack = 50}  
DefineDllFunc: "d:\msvc\bin\testdll.dll", FLOAT,  "calcr2v", LPFLOAT, WORD, 
WORD, INT;   

VARS: X(0), Y(0), Z(0), VARSTRT(0), VARSZ(0);

Z = Close;
VARSTRT = VarStartAddr(Z);                            
VARSZ = VarSize(Z);                                            

if CURRENTBAR > 20 then begin
for x = 19 downto 0 begin                                   
     Y = calcr2v(&Z, VARSTRT, VARSZ, X);
    print(" X ", X, " Y ",  Y);
end;
end;

*********************************************************************
The DLL is below. 
***********************************************************************
#include <windows.h>    
#include "c:\omega\prog\ts_kit.h"
float FAR PASCAL calcr2v(LPFLOAT price, WORD wStartAddr, WORD wSize, int iX)

LPFLOAT lpNewAddr; 
double wkprice;
float  fval;

lpNewAddr = FindAddress_Var(price, iX,wStartAddr,wSize);     
wkprice = *lpNewAddr;
fval = wkprice;
return(fval);