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

Re: Special thread for Pierre Orphelin, the man who do not want to see



PureBytes Links

Trading Reference Links

Hello,

:) i think know why it is going so wrong in TS

The things is that TS does not use floating point in it's rates
representation and may be calculations.
This is what i learn while looking on TS 4.0  DDE protocol - there is all
quote (chart) data  represented
with WORDS (2bytes - 16bit) only data!!!
yes this mean that maximum WORD value is 0xFFFF or 65535 (decimal)
also they use special parameter, which mean there decimal point should be
located,
or in other words - say 1234 - in decimal, with (ex. JPY param is 0.1) it
will give 123.4 for JPY
All is ok, until special cases like that you showed below. :)
that is that at 5th significant digit sometimes numbers are lost.

:)

I have been looking at this for a day now. If there is a fault in my logic,
I can not find it without help. At the same time, if I am right there is a
tremendous error in Tradestation causing a lot of things to go wrong, really
going wrong that is a bigger error than I would ever have thought should
have gone through unnoticed. Well, to decide which it is, I send you an
indicator that illustrates a math error. Some of you will recognise it as
part of the code from the dmiplus logic from the built in library. This
explains the bad formatting. Did not want to change more than necessary.
Please tell me if I am missing something here, this has made me totally lose
confidence in Tradestation indicators.

What you can see in the indicator code is first a number of lines with fix
numbers, calculating the base for the dmiplus14 variable from within dmiplus
using the fix numbers. Then you can see the logic again, but now calculating
on high and low figures as usual. The first part, the one with fixed
figures, should for all that I can understand plot as a straight line at
zero, but plots at 0.107. The second plot is really not very interesting,
just part of my fault tracing.

The problem with the calculation error now is bigger than the old question
of single precision compared to double precision. The problem is that
Tradestation does some very funny things with calculations (you have
previously maybe seen the mails about Tradestation not showing full number
of decimals, and also of Tradestation not beeing able to handle 2000/close
contracts for old stock data where prices are a bit low since number of
contracts overflows at 65000 contracts). From all what I can figure,
Tradestation must be using a math library of its own, since even single
precision calculations should result in a line plotting as zero instead of
above zero. C++ code doing the same calculations in single precision results
in a zero line.

Tradestation is thus not just bad at calculactions only due to single
precision logic. Neither is it unsuitable for backtesting stock data only
due to the stupid notion of converting data from 1984 to integers based on a
conversion factor suitable for price levels from 2001. It is actually buggy
due to calculations using some math routines that are lacking precisions in
a way that I can not compare to anything but the old Sinclair handheld
calculators from 1974.

Why did I discover this, which I can only see as a bug? What happened was
that I got funny results during backtests, so I started tracking what
happened. I knew that price conversion to integers was a source for very big
errors, I knew that single precision would add to those errors, I knew that
figures shown would not be the real figures due to the decimal printout bug,
but what I saw was accumulators accumulating to levels that did not have to
do with price errors or precision errors but something else. The DMI
calculations builds on accumulators (as seen in the code from where the
enclosed indicator code comes). These accumulators accumulate when they
should not, due to the above mentioned bug in calculations, increasing dmi
levels when there should be no increases, resulting in exits coming way off
from what they should. To this can then be added the single precision error
in the calculations.

To test, create a new indicator calling it whatever you like and insert the
below code into it:
var: plusdm(0);
var: minusdm(0);
var: plusdm1(0);
var: minusdm1(0);
If 10.387 - 10.280 < 0 Then
PlusDM = 0
Else
PlusDM = 10.387 - 10.280;
If 10.280 - 10.173 < 0 Then
MinusDM = 0
Else
MinusDM = 10.280 - 10.173;
If MinusDM >= PlusDM Then
PlusDM = 0;
plot1 (plusdm);
If High[0] - High[1] < 0 Then
PlusDM1 = 0
Else
PlusDM1 = High[0] - High[1];
If Low [1] - Low [0] < 0 Then
MinusDM1 = 0
Else
MinusDM1 = Low[1] - Low[0];
If MinusDM1 >= PlusDM1 Then
PlusDM1 = 0;
plot2(plusdm1);

It should plot a straight line at zero, but does not.