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

Oddball Variation 1.2



PureBytes Links

Trading Reference Links

This fixes a functional bug wherein buyzone was being used for both buy and
sell statements and sellzone was ignored; this snuck in in the course of
experimentation by me.  Also, minor doc and code cosmetic improvements.

{Variation of Mark Brown's Oddball System

Author:  Charles Johnson - cmjohnsonxx@xxxxxxxxx

Date:  Oct 29, 2001

Version:  1.2

Revision history:
1.0, 10/13/01, initial release
1.1, 10/27/01, efficiency and documentation improvements; no
functional changes.
1.2, 10/29/01, fixed "if osc < buyzone then sell;", cleaned up
parens in osc, minor doc clarifications.

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, consolidated from his article
and subsequent postings, is:

...

{RL = 8 for S&P futures, 7 for SPY}
Inputs: RL(8), BZ(3), SZ(1);

{Eastern time; you may have to adjust for your time zone.}
{last bar traded is 1600 for futures, 1500 for SPY}
if time > 930 and time <= 1600 then begin
value1 = ((close of data2 / close[RL] of data2) -1) * 100;
If value1 > BZ then buy;
If value1 < SZ then sell;

...

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

Natural hour hourly bars are used.  7 hourly bars are generated,
plus an extra one at 4:15 for futures.  The last bar traded for
futures is the 4 pm bar; there are 15 minutes to place an order.
The SPY market closes at 4, so for SPY the 3 pm bar is the last
bar traded.

The number of bars Mark's version will reference is equal to RL.

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.
However, I am informed that 60 minute bars can be made to form on
hour boundaries for third-party data if the symbol's session time
is changed to start on an even hour, e.g., 10 am.

This variation gives the same results as Mark's program 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:

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 for the time period traded, as Tradestation will skip missing
data1 and the program will skip missing data2, impairing the trading
logic.  The program is not adversely affected by spotty data outside
of the times traded, e.g. night session data.

The start parameter 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.

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 my experimentation and testing of
Mark Brown's concept, and am sharing the code with others.

Additional risk control may be 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)}

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

var: osc(0), firsttime(0), initialized(false), idx(0);

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

if initialized = false then begin
	firsttime = timetominutes(first);
	initialized = true;
end;

if time >= first and time <= last then begin

	idx = (timetominutes(time) - firsttime)/interval;
	if fracportion(idx) = 0 and idx >= 0 then begin
		if obvalue[idx] > 0 and close of data2 > 0 then
			osc = ((close of data2 / obvalue[idx]) - 1) * 100;
		if close of data2 > 0 then obvalue[idx] = close of data2;
	end;

	{The code (not the initial heading) in one and only one of the
	following three sections should have the braces removed to change
	it from a comment to active code.}

	{for Tradestation 2000i:}
	if osc > buyzone then buy;
	if osc < sellzone then sell;

	{for Tradestation 6:}
	{if osc > buyzone then buy this bar;
	if osc < buyzone then sell short this bar;}

	{for a Tradestation indicator:}
	{
	Plot1(osc,"roc");
	Plot2(buyzone,"bz");
	Plot3(sellzone,"sz");
	}

end;