PureBytes Links
Trading Reference Links
|
An alert reader has uncovered a bug which caused the "last" parameter to
round up to the next full interval. The problem was in the
initialization routine; here is the corrected version.
{Variation of Mark Brown's Oddball System
Author: Charles Johnson - cmjohnsonxx@xxxxxxxxx
Date: Oct 23, 2001
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.
Usage:
Data1 is the tradeable, data2 is the advancing issues
of the NYSE (in Tradestation, $ADV; in quote.com QC:ADVN.NY).
One hour bars are used by default. 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, this setting doesn't work and 60 minute bars will
form on half-hour boundaries; 30 minute
bars can be used to allow polling on the hour.
Assuming one hour bars, for the S&P there will be hourly bars
from 10 am to 4 pm eastern (9 to 3 Central time) plus a final
4:15 pm (3:15) bar. For SPY there will not be a 4:15 bar.
Mark suggests not trading the 4 pm bar for SPYs, because
the market closes at 4, as opposed to 4:15 for futures.
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;
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.
The program will work with any length bars, as long as their length
is equal to or less than the interval. Data outside the start and
end times, such as night session data, is ignored.
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 deep drawdowns and long underwater/flat periods,
and properly account for commissions and slippage in testing.
I have run this program only on 2000i.
Feel free to share your findings and improvements.
-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
value1 = 0;
minutes = timetominutes(last);
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 = 1 to value1 begin
if minutes = obtime[value2] then begin
if obvalue[value2] > 0 then begin
indicator = ((close of data2) / obvalue[value2] - 1) * 100;
{"crosses over" rather than ">" allows addition of
exit strategies without unwanted immediate reentry}
If indicator crosses over buyzone then action = 1;
If indicator crosses under sellzone then action = -1;
end;
obvalue[value2] = close of data2;
end;
end;
if action = 1 then buy;
if action = -1 then sell;
-----Original Message-----
From: cwest@xxxxxxxxxxxx [mailto:cwest@xxxxxxxxxxxx]
Sent: Tuesday, October 23, 2001 12:29 PM
To: Charles Johnson
Subject: RE: which oddball?
Done. Thanks Charles. Even if you search for "intraday momentum system" the
oddball system will rank first.
Colin
|