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

More Possible Errors in OddBall



PureBytes Links

Trading Reference Links

In tracing differences between various versions of OddBall, I found a 
lot more possible sources of error than I had thought of before - 
mostly related to missing data bars in data1 or data2. TradeStation 
gives you some strange behavior if there are bars missing in either 
data series in a multiple data series chart.

On bars with data1 missing but data2 present, the code will be 
executed but the CurrentBar value will NOT be incremented and the new 
value of variables will NOT be saved - very strange. The data1 values 
(Time, Date, Close, etc.) will be the values from the last real data1 
bar.

Bars with data2 missing but data1 present will be executed normally. 
The data2 values (Time, Date, Close, etc.) will be the values from 
the last real data2 bar.

(This is from testing in TS2000i - it could be different in other 
versions...)

Needless to say, this plays havoc with the OddBall scheme of 
referring back 7 bars and expecting to find the corresponding time 
bar from yesterday!

To trace these, I created an error reporting function that will print 
a log of all errors in the debug log. Each bar with errors prints a 
line in the log listing the error codes. A bar can have multiple 
errors. An example of the log with the error codes is appended below. 
Note that the error count does not always increment (because the 
data1 bar is missing).

This list of the errors was for the original OddBall code running on 
four years of my data. (60 minute natural hour bars) Every error 
results in an incorrect calculation of the rate-of-change for that 
bar so could cause a spurious change in the trading position. There 
are 124 bars with errors in the list below (but I omitted most of 
them from the middle of the list to shorten the message).

Many of the errors are due to short trading days near holidays as we 
have discussed previously, but there are still a lot due to missing 
data bars. As an example:

Count Days   ---Cursor--   CurrentBar1   CurrentBar2   --RefBar1--   --RefBar2--   LDate1   LDate2   j   k  Error
    1  124   980701 1000   980630 1600   980701 1000   980629 1600   980630 1000   980629   980629   0   7  B1 D2

This finds that on chart bar of 7/1/98 at 10:00am, the data1 bar is 
missing. The values on data1 will show 6/30/98 4:00pm even though the 
bar isn't there.


    1  125   980701 1100   980701 1100   980701 1100   980630 1000   980630 1100   980630   980701   0   7  D2 T1

As a result, on the chart bar of 7/1/98 at 11:00am, the time on data1
and the date on data2 seven bars back are not correct. Note that the 
error count on column 1 did not increment because calculated value: 
"Count = Count + 1" was not saved because the data1 bar are missing.


Perhaps this helps explain why people have been getting such 
different results with the original OddBall code...

I will try to test other OddBall code versions later. Clearly we 
would need to use some more robust way of implementing OddBall if we 
want to prevent errors due to missing data bars and short trading 
days.

Bob Fulks

----------

Error Codes:

ID = Z   [Zero divisor in Rate-of-Change Calculation]
ID = B1  [On this bar data1 bar missing, data2 bar present]
ID = B2  [On this bar data2 bar missing, data1 bar present]
ID = T1  [Time on bar back in time is wrong in data1]
ID = T2  [Time on bar back in time is wrong in data2]
ID = T   [Time on bar back in time is wrong in data1 and data2]
ID = D1  [Date on bar back in time is wrong in data1]
ID = D2  [Date on bar back in time is wrong in data2]
ID = D   [Date on bar back in time is wrong in data1 and data2]

Column Headings:

Count        Error count (but it will not increment if missing data1 bar)
Days         The day number since the beginning of test
Cursor       The date/time at the cursor on a chart (to locate bars)
CurrentBar1  The date/time of current bar data1
CurrentBar2  The date/time of current bar data2
RefBar1      The date/time of bar back in time data1
RefBar2      The date/time of bar back in time data2
LDate1       Saved date of the previous trading day data1
LDate2       Saved date of the previous trading day data2
j            The index j (if used, zero if not used)
k            The index k (bars back to reference bar)
Error        Error codes for this bar (see above)



Count Days   ---Cursor--   CurrentBar1   CurrentBar2   --RefBar1--   --RefBar2--   LDate1   LDate2   j   k  Error
    1  124   980701 1000   980630 1600   980701 1000   980629 1600   980630 1000   980629   980629   0   7  B1 D2
    1  125   980701 1100   980701 1100   980701 1100   980630 1000   980630 1100   980630   980701   0   7  D2 T1
    2  125   980701 1200   980701 1200   980701 1200   980630 1100   980630 1200   980630   980701   0   7  D2 T1
    3  125   980701 1300   980701 1300   980701 1300   980630 1200   980630 1300   980630   980701   0   7  D2 T1
    4  125   980701 1400   980701 1400   980701 1400   980630 1300   980630 1400   980630   980701   0   7  D2 T1
    5  125   980701 1500   980701 1500   980701 1500   980630 1400   980630 1500   980630   980701   0   7  D2 T1
    6  125   980701 1600   980701 1600   980701 1600   980630 1500   980630 1600   980630   980701   0   7  D2 T1
    7  126   980702 1000   980702 1000   980702 1000   980630 1600   980701 1000   980701   980701   0   7  D1 T1
    8  229   981127 1500   981127 1400   981127 1500   981125 1400   981125 1500   981125   981125   0   7  B1
    8  229   981127 1600   981127 1400   981127 1600   981125 1400   981125 1600   981125   981125   0   7  B1
    8  230   981130 1000   981130 1000   981130 1000   981125 1500   981127 1000   981127   981127   0   7  D1 T1
    9  230   981130 1100   981130 1100   981130 1100   981125 1600   981127 1100   981127   981127   0   7  D1 T1
   10  230   981130 1200   981130 1200   981130 1200   981127 1000   981127 1200   981127   981127   0   7  T1
   11  230   981130 1300   981130 1300   981130 1300   981127 1100   981127 1300   981127   981127   0   7  T1
   12  230   981130 1400   981130 1400   981130 1400   981127 1200   981127 1400   981127   981127   0   7  T1
   13  230   981130 1500   981130 1500   981130 1500   981127 1300   981127 1500   981127   981127   0   7  T1
   14  230   981130 1600   981130 1600   981130 1600   981127 1400   981127 1600   981127   981127   0   7  T1
   15  248   981224 1400   981224 1400   981224 1300   981223 1400   981223 1300   981223   981223   0   7  B2
   16  248   981224 1600   981224 1400   981224 1600   981223 1400   981223 1400   981223   981223   0   7  B1 T2
   16  249   981228 1000   981228 1000   981228 1000   981223 1500   981223 1500   981224   981224   0   7  D T
   17  249   981228 1100   981228 1100   981228 1100   981223 1600   981223 1600   981224   981224   0   7  D T
   18  249   981228 1200   981228 1200   981228 1200   981224 1000   981224 1000   981224   981224   0   7  T
   19  249   981228 1300   981228 1300   981228 1300   981224 1100   981224 1100   981224   981224   0   7  T
   20  249   981228 1400   981228 1400   981228 1400   981224 1200   981224 1200   981224   981224   0   7  T
   21  249   981228 1500   981228 1500   981228 1500   981224 1300   981224 1300   981224   981224   0   7  T
   22  249   981228 1600   981228 1600   981228 1600   981224 1400   981224 1600   981224   981224   0   7  T1
   23  289   990226 1000   990225 1600   990226 1000   990224 1600   990225 1000   990224   990224   0   7  B1 D2
   23  289   990226 1100   990225 1600   990226 1100   990224 1600   990225 1100   990224   990224   0   7  B1 D2
   23  290   990226 1200   990226 1200   990226 1200   990225 1000   990225 1200   990225   990226   0   7  D2 T1
   24  290   990226 1300   990226 1300   990226 1300   990225 1100   990225 1300   990225   990226   0   7  D2 T1
   25  290   990226 1400   990226 1400   990226 1400   990225 1200   990225 1400   990225   

<Big snip>

   93  932  1010917 1600  1010917 1600  1010917 1600  1010911 1200  1010910 1600  1010911  1010910   0   7  T1
   94  980  1011123 1400  1011123 1400  1011123 1300  1011121 1400  1011121 1300  1011121  1011121   0   7  B2
   95  980  1011123 1600  1011123 1400  1011123 1600  1011121 1400  1011121 1400  1011121  1011121   0   7  B1 T2
   95  981  1011126 1000  1011126 1000  1011126 1000  1011121 1500  1011121 1500  1011123  1011123   0   7  D T
   96  981  1011126 1100  1011126 1100  1011126 1100  1011121 1600  1011121 1600  1011123  1011123   0   7  D T
   97  981  1011126 1200  1011126 1200  1011126 1200  1011123 1000  1011123 1000  1011123  1011123   0   7  T
   98  981  1011126 1300  1011126 1300  1011126 1300  1011123 1100  1011123 1100  1011123  1011123   0   7  T
   99  981  1011126 1400  1011126 1400  1011126 1400  1011123 1200  1011123 1200  1011123  1011123   0   7  T
  100  981  1011126 1500  1011126 1500  1011126 1500  1011123 1300  1011123 1300  1011123  1011123   0   7  T
  101  981  1011126 1600  1011126 1600  1011126 1600  1011123 1400  1011123 1600  1011123  1011123   0   7  T1
  102 1001  1011224 1400  1011224 1400  1011224 1300  1011221 1400  1011221 1300  1011221  1011221   0   7  B2
  103 1001  1011224 1600  1011224 1400  1011224 1600  1011221 1400  1011221 1400  1011221  1011221   0   7  B1 T2
  103 1002  1011226 1000  1011226 1000  1011226 1000  1011221 1500  1011221 1500  1011224  1011224   0   7  D T
  104 1002  1011226 1100  1011226 1100  1011226 1100  1011221 1600  1011221 1600  1011224  1011224   0   7  D T
  105 1002  1011226 1200  1011226 1200  1011226 1200  1011224 1000  1011224 1000  1011224  1011224   0   7  T
  106 1002  1011226 1300  1011226 1300  1011226 1300  1011224 1100  1011224 1100  1011224  1011224   0   7  T
  107 1002  1011226 1400  1011226 1400  1011226 1400  1011224 1200  1011224 1200  1011224  1011224   0   7  T
  108 1002  1011226 1500  1011226 1500  1011226 1500  1011224 1300  1011224 1300  1011224  1011224   0   7  T
  109 1002  1011226 1600  1011226 1600  1011226 1600  1011224 1400  1011224 1600  1011224  1011224   0   7  T1