PureBytes Links
Trading Reference Links
|
I am going to try writing DLL's for TS4/SC4. I have PowerBasic DLL 2.0
compiler which generates a small, fast 16 bit DLL. I am proficient at
PowerBasic for DOS (which is 90% the same as PBDLL) and with it have
written a lot of complex stuff: database, test programs, etc. for
engineering applications. This includes math like MESA, FFT's,
polynomial curve fitters, etc. But, I have never written a Windows DLL.
However I read the PB DLL 250 page instruction manual and have no doubts
that after stumbling a bit, I can make it work with TS. Also, I know of
one TS add-on vendor using PB for the DLL in his product. I think that
PowerBasic's 16 bit DLL compiler is now around $60. It used to be $150
but who wants 16 bit stuff now-a-days (I do).
When I get this working and am comfortable with it, I will then offload
EL math like T3 MA's, statistical calculations, etc. Then maybe some of
the conditional testing if there is a benefit. I expect the math to run
faster and because EL has to do less, I expect to never get near the 64K
limit. Also, numerical accuracy can be better because the DLL can
convert between EL single precision float and Basic's double precision
float, and store intermediate results between bar calculations in DLL
specified memory.
So that I can get off on the right foot, I would appreciate answers to
the following questions regarding interface to EL, from those who have
already ventured into DLL land:
NOTE: My application is EOD only.
1) Omega's USERDLLS.WRI states that the EL DLL interface will support
the following data types: BYTE, CHAR, INT, WORD, LONG, DWORD, FLOAT,
DOUBLE, BOOL. I thought that EL was limited to single precision float,
character string and TRUE - FALSE. Basic will handle all of those other
data types but what good is it to pass them back and fourth to EL?
2) Regarding TS_KIT that comes with TS and SC. I sort of see the
usefulness of TS_KIT.DLL. However, what use is TS_KIT.H and TS_KIT.LIB
to me? Perhaps for "C", but compiled Basic needs no header file and the
Basic DLL can call another DLL. So, are the H and LIB files strictly
for C?
3) The only documentation I've seen on interfacing EL to a DLL is
Omega's USERDLLS.WRI, the Investment Engineering's Global Variables
documentation and HASHNUMS documentation. The Omega DLL stuff is
vintage 1992. Has Omega ever updated? Is there any other documentation
on this subject?
4) I have questions based on a hypothetical application example.
Answers may disclose ways to speed up an optimization run and might
also open the door to walk-forward optimization. Say we want to
calculate both a forward moving T3 MA and a reverse moving T3 MA for
Close of a historical daily price series. These will be averaged at
each bar to make a lowpass filter with no delay (no predictive power but
might be good for an "anchored momentum" indicator). Say we declare an
array in the DLL for all "C Of DATA1" and move that data from EL to the
DLL array. The DLL will then calculate the forward and reverse MA's and
place the composite for each bar in a second DLL array which is the
delayless MA for each bar. Say we will do buy and sell trigger
optimization in TS but not change MA parameters and therefore for
highest speed, don't want to re-calculate MA's on each optimization run.
Questions for this case are:
a) Say the DLL gets the data series from TS and calculates the
delayless MA for each bar in the series when CurrentBar = 1? TS then
gets the delayless MA for each bar from the DLL as TS moves forward for
each bar (when CurrentBar is > 1). So, how can we get data for bars in
the future while CurrentBar = 1? That data does exist in a file
previously downloaded by the Omega Downloader. And, when we key in an
optimization run, how do we prevent TS from re-running CurrentBar = 1
over and over again? Is it as simple as setting a switch after the
first pass, to skip initialization (calculating MA's) forever more?
b) If it is not possible for TS to look forward in the historical data
series when CurrentBar = 1, then can TS be forced to do two passes? On
first pass get and move the data to the DLL which will calculate MA's.
On second pass run the trading system or plot the indicator. On
optimization runs, don't make the DLL calculate MA's again.
Your help will be very much appreciated. When I get my first DLL
running, I will post it (its source code) to the list.
Thanks, Barry
|