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

Repaired and tested Oddball variation



PureBytes Links

Trading Reference Links

In fixing the previous bug, I created other problems.  I have just spent a
couple of hours fixing and testing the program, and it seems to work
correctly now.  Please let me know if you encounter further problems.

My apologies for this.  I thought I'd share a quick and dirty program. It's
now not so dirty or so quick.

In the testing process, I discovered some useful things which I've
incorporated into the revised embedded documentation.

Below is the corrected code.  I have also attached it as an ELA file.

{Variation of Mark Brown's Oddball System

Author:  Charles Johnson - cmjohnsonxx@xxxxxxxxx

Date:  Oct 23, 2001

Version:  1.0

Functional Description:

See Mark Brown's article in Active Trader Magazine, Dec 2000;
http://www.activetradermag.com, also see
http://www.oddballsystems.com.

Mark Brown's concept is to trade S&P futures or SPY stock
off the hourly rate of change in market breadth from the same
time one day ago.

The basic program from Mark Brown is:

Inputs: RL(7), BZ(3), SZ(1); {RL = 7 for SPY, 8 for S&P}
value1 = ((close of data2 / close[rl] of data2) -1) * 100;
If value1 > bz then buy;
If value1 < sz then sell;

(Natural hour bars with S&P futures but not with SPY will
generate a 4:15 bar.)

This variation gives the same results when settings are similar,
but allows more flexibility, allowing experimentation with
different bar lengths, intervals, start and end times.  It can serve
as a base for tinkering and expansion.

Usage:

Data1 is the tradeable, data2 is the advancing issues
of the NYSE (in Tradestation, $ADV; in quote.com QC:ADVN.NY).

On the first day the program sees, values are stored in an
array for comparison.  Actual trading starts on the second
day.  Maximum bars the stategy will reference may be set to
zero.

Bar length can be any value equal to or less than the interval.
A bar length should be chosen that will have data on every
bar, as Tradestation will skip missing data1 and the program
will skip missing data2, impairing the trading logic.

To force bars to form on hour boundaries, "natural hour bars"
can be set if the data is in the 2000i global server database.
For 3rd party data (in back testing), this setting doesn't work
and 60 minute bars will form on half-hour boundaries; 30 minute bars
and an interval of 60 can be used to allow polling on the hour.

The start time must be on a boundary of the bar length.
For example, starting at 10:32 with 5 minute bars will generate
no trades, as there are no bars with times of 10:32, 10:37, etc.

Mark suggests not trading the 4 pm bar for SPYs, because
the market closes at 4, as opposed to 4:15 for futures.
So for SPY on hourly bars, "last" should be set to 1500
and for futures to 1600.

Disclaimer:

I am releasing this code into the public domain, and I make no
representation whatsoever as to its suitability for any purpose,
including trading.

I wrote it to facilitate experimentation and testing of Mark
Brown's concept.  Additional risk control seems desirable.

I suggest that anyone interested in trading this or any
strategy conduct rigorous backtesting and pay careful attention
to risks such as drawdowns and underwater/flat periods,
and properly account for commissions and slippage in testing.

I have run this program only on 2000i.

Feel free to share findings and improvements and report bugs.

-Charles Johnson (cmjohnsonxx@xxxxxxxxx), 10/23/01}

inputs:	buyzone(3), {buy when indicator crosses over}
		sellzone(1), {sell when indicator crosses under}
		first(1000), {time of first polling; default is 10 am Eastern time}
		last(1600), {time of last polling; default is 4 pm Eastern time}
		interval(60); {minutes between pollings}

var: indicator(0), action(0), minutes(0), initialized(false);

{array size must be >= number of polling times.
60*60*6.75=405 will hold 1 minute pollings for complete S&P day session}
array: obtime[1000](0), obvalue[1000](0);

if initialized = false then begin
	obtime[0] = timetominutes(first);
	value1 = 0;
	minutes = timetominutes(last) - timetominutes(first);
	while minutes >= interval begin
		value1 = value1 + 1;
		obtime[value1] = obtime[value1-1] + interval;
		minutes = minutes - interval;
	end;
	initialized = true;
end;

action = 0;
minutes = timetominutes(time);
for value2 = 0 to value1 begin
	if minutes = obtime[value2] then begin
		if obvalue[value2] > 0 and close of data2 > 0 then begin
			indicator = ((close of data2) / obvalue[value2] - 1) * 100;
			If indicator > buyzone then action = 1;
			If indicator < sellzone then action = -1;
		end;
		obvalue[value2] = close of data2;
	end;
end;

if action = 1 then buy;
if action = -1 then sell;

Attachment: Description: "ODD7 V1.ELA"