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

Bugs in OR EL Functions



PureBytes Links

Trading Reference Links

I've just run across what appears to me to be a couple of serious bugs in
the CloseD function which is distributed with TradeStation 4 (I purchased
in August and have build 21).

Is there a list available of known bugs?  Anything compiled here by the
Omega-List?  Anything compiled by Omega?  Other?

If not, I think we (Omega-List) should start one.  I'd be willing to
assist/manage the maintanence.

The bugs...  (which cost me a couple of hours)

Bug #1: Can't call it more than once per bar
--------------------------------------------

When called, the OR CloseD function does two main things.  First it updates
an array it keeps of the last 50 daily closes, and secondly it returns the
close that was asked for.

The updating part checks if the DATE value just switched to a new value
indicating the beginning of a new day and the definition of a new daily
close (Close[1]).  If DATE <> DATE[1] (new day) then shift the array and
store Close[1] in the "front".

This works fine as long as you only call CloseD() *once* per bar.  If it is
called more than once (e.g. in a loop) it shifts the value everytime you
call it (on the first bar of the day).

I've now created my own version of CloseD which stores the date when a
shift is done and only shifts when DATE > ShiftedDate instead of DATE >
DATE[1].


Bug #2: Must be called every bar to work
----------------------------------------

Last week I was asking about what TS is doing in the background when it
executes EasyLanguage systems and indicators.  I asked if it was executing
all referenced functions ahead of the actual indicator/system code and then
just referencing the values.  Something led me to believe that was the
case.  That is not the case.  The code is executed when called.  If this is
the case (as it appears from the PRINT logging I was using to debug), the
CloseD will also fail to work if it is not executed on every bar.  i.e if
the only call to CloseD is inside an IF-THEN block, the internal CloseD
array won't get updated if the IF-THEN condition turns out FALSE on the
first bar of some days.

...that is why I asked about whether functions were executed on every bar,
regardless of whether they were called.

Code Example: (EOD 3 bar MA on intraday chart)

	*** DON'T TRUST THIS CODE - IT WON'T WORK RIGHT ***

	VAR: index(0), sum(0);
	IF BarNumber > 100 THEN BEGIN
		sum = 0;
		FOR index = 1 TO 3 BEGIN
			sum = sum + CloseD(index);
			PRINT(FILE("E:\DEBUGLOG.txt"),BarNumber:4:0," ",Date:6:0," index = ",
index:2, " sum = ",sum:4:2);
		END;
		PLOT1(sum/3, "EOD-MA3");
	END; 

	*** DON'T TRUST THIS CODE - IT WON'T WORK RIGHT ***

In this case, CloseD isn't executed until the 101st bar.  On this bar,
CloseD is called 3 times.  The first time it will return the Close from the
day before, and the second and third times it will return -1 because it
wasn't executed on the two previous days (since BarNumber <= 100) and the
internal array wasn't updated.

I can't find any documentation to warn about these gotcha's.

David Wieringa
Scottsdale, AZ