Whenever a backtest is run, the output includes a short link to the
backtest, build from a 6-character alphanumeric code. These codes are
arbitrary, and have no meaning other than pointing back to a particular
screen. There is also a longer code for a backtest, which looks like
https://backtest.org/ST(Small_Value)15.
The part at the end ("ST(Small_Value)15
") contains
everything you need to know to reproduce the test run.
Common to all testers:
All codes are of the form:
[name:
] [fftt] [mm] [options] TT [tester-dependent].
The TT is the two-letter uppercase code for the specific tester,
which is listed with each tester description on the right. A name may be
included before the code, followed by a colon. The name may consist of
letters, numbers, underscore, dot, and dash. It can actually contain other
characters as well, but they will be tilde-encoded (like the percent-encoding
used in URLs, except with a tilde). The numbers at the beginning of the code,
the fftt [mm], are interpreted as follows:
fftt | Starting and ending ("from", "to") years of the backtest, two digits each (yes, that leads to Y2K-type problems - So sue me if I live until 2069). The default is the range over wich the backtest is valid. |
mm | Starting month of the run, two digits, 01-12. Defaults to January. |
The general options at the beginning of the code mostly come from the trading simulator. They may appear in any order, though they should come after the year/month numbers. The options are:
r |
Run the test with HTML output. Normally, following the link won't actually run a test, but just present the setup screen ready for running. |
x |
Run the text with CSV output for exporting to a spreadsheet. This is implied if the tester is run from the command line, or a "*.csv" file is run. |
u |
Allow direct entry of screen codes, instead of the normal pulldown menus. That's why you're reading this guide. |
m |
List selections and gains for all months, not just trade months. |
h # |
Holding period, between 1 and 24 months. The default is one month. |
n # |
Number of screens, for testers that allow multiple screens. |
t |
Use the trading simulator. This allows the entry of the extra parameters below, and is implied if any of those are set. |
i # |
Initial allocation, defaults to $10000. |
a # |
Amount to add periodically |
ah # |
How often to add money |
f |
Fixed allocation |
b # |
Rebalance period. Defaults to one month; may be 0 to never rebalance. |
c # |
Commission |
s # |
Percent spread |
st # |
Short-term capital gains taxes |
lt # |
Long-term capital gains taxes |
th # |
How often to take taxes out |
l # |
How many days trades lag rankings |
The last part of the code is interpreted by the specific tester used. They generally share a common format of one or more screen codes followed by options. Screen codes are inside parentheses, in one of two forms. They may be the name of one of the standard MI screens or one of a handful of indices. Also, any backtest code can be used as a screen code; this code fragment may in turn contain other screen codes with their own backtest codes in parentheses. The global options listed above, including the date information, are not included - those options will come from the backtest using the code, and will be stripped from the code if found (allowing for easy cut-and-paste).
Standard Backtester
ST ss # #
Ss is a screen code, followed by two 1-or-2 digit numbers, which
are the ranks to buy. Note the two numbers are run together without any
spaces or other separators. A 2-digit code is easy, e.g. 15
is ranks 1-5. A 4-digit code is two 2-digit ranks,
e.g. 1025
is ranks 10-25. A 3-digit code is a 1-digit rank
and a 2-digit rank. e.g. 110
is ranks 1-10.
This "from-to" rank encoding appears in many other testers as well.
Screen Builder
SB [(T
# # | ss) X
] rule [X
rule ...]
A screen is defined by a series of rules, separated by uppercase
"X
". Rules are made up of field names,
numbers, strings, and algebraic operators.
The first rule may be a screen code, or a database specifier marked by a
capital "D
" and a lowercase name.
The field names are made up of lowercase letters, digits, and underscores.
are listed in the Screen Builder Field Guide.
Numbers consist of digits and an optional decimal point. Strings are any
text surrounded by capital "Q
" (see below); all letters in
strings must be lowercase, and all special symbols must be properly
encoded. Operators (and a few other related symbols) are capital letters
with the following encodings:
A |
+ (Add) |
B |
Bottom |
C |
) (Close parenthesis) |
D |
/ (Divide) |
E |
= (Equals) |
F |
, (Field separator) |
G |
> (Greater than) |
H |
% (Hundredths) |
I |
& (Intersection) |
L |
< (Less than) |
M |
* (Multiply) |
N |
! (Not) |
O |
( (Open parenthesis) |
Q |
" (Quote) |
S |
- (Subtract) |
T |
Top |
V |
| (Union, but U used to be reserved) |
Syntactically, a rule is any free-form concatenation of the above parts. But in reality, it must make sense to the computer.
Screen of Screens
SS ss [...] [#] [m
#] [(u
| s
) #] [l
#]
First, the screen codes are listed for all screens used in the SOS. Next
comes the number of positions to use per screen. Then the maximum score
is preceded by a lowercase "m
" (defaults to the number of
positions). If the SOS must match a minimum number of screens, that
number is preceded by a lowercase "s
" (or a lowercase
"u
" if the screens should be unique). If there's a limit of
stocks to select, it's preceded by a lowercase "l
" (that's
not a one or an uppercase "I
"). This limit code is used in
many testers.
Blender
BL ss [# #] [p
#] [h
#] ... [b
#]
For each screen in the blender, the following:
First, the screen code, optionally followed by the ranks for that
screen (if the screen isn't a backtest code). Optionally, a percentage of the
portfolio to allocate to that screen (defaults to split evenly) preceded by
a lowercase "p
", and a holding period preceded by
"h
".
By default, the blender (as opposed to the sceens within the blend) is
rebalanced annually. A different rebalance period may be specified with
"b
", which may be 0 to never rebalance.
Overlap
OV ss ss pad # # [l
#]
First, the screen codes for the two screens to overlap. This is followed
by a single-digit pad code: 0=none, 1=first, 2=second, 3=both. Then the
ranks to hold in the Standard format. If there's a limit of stocks to
select, it's preceded by a lowercase "l
".
Hold-'Til-Drop
HD ss [ss] # # [s
#] [t
#]
First, the screen code the the "buy" screen, followed by the "transition"
screen if there is one. Next are the ranks to buy. The "sell below"
rank, if any, is preceded by a lowercase "s
". If there's a
"sell below" rank for the transition screen, it's preceded by a lowercase
"t
".
Dozens
DZ ss tt (t
# | # #) [n
| m
| c
| s
]
First, the screen code, followed by the trading period. In "dozens" mode,
i.e. buy some number of stocks not already held, the number of stocks per
period is preceded by a lowercase "t
". In "dual semi" mode,
indicate the ranks to hold in the Standard format.
A rebalance code may be specified: "n
" for no rebalancing,
"m
" for margin rebalancing, "c
" for cash
rebalancing, and "s
" for cash rebalancing with a shown
balance. If no code is specified, it defaults to "m
".
Screen Switching
SW ss ss ss [# #] p
# c
# [h
]
First, the screen codes are listed for the index, the low screen, and the high screen. The index may be a regular screen code, or one of the following index codes:
dj |
Dow Jones Industrial Average |
nq | Nasdaq Composite |
nx | Nasdaq 100 |
ru | Russell 2000 |
ox | S&P 100 |
sp | S&P 500 |
ts |
S&P 500, dividend-adjusted |
After the screens are the ranks to buy/compare (unless the screens are
backtest codes, in which case all ranks are used). The number of periods
to look back is preceded by a lowecase "p
", and the
percentage cutoff for the index screen is preceded by a lowercase
"c
". The hold-'till-switch option is specified by a
lowercase "h
".
All-Months Summary
AM ss [# #]
The all-months codes don't include the mm part of the standard code header, since there is no one month associated with the summary.
First a screen code, followed by the ranks to use. If the screen is a backtest code, no ranks are specified.
Options Simulator
OP ss [# #] v
# (l
| s
| c
| p
| C
| P
| v
| d
| t
) # [o
# m
#] ...
First, the screen code to pick options from. Next are the ranks to use
(unless the screen is a backtest code, in which case all ranks are used).
The volatility percentage is preceded by a lowercase "v
".
Then for each option category:
First, an option code: l
(long stock), s
(short
stock), c
(call), p
(put), C
(write call), P
(write put), v
(covered call),
d
(cash), or t
(T-bills). Next, the percentage
of the portfolio to put into this option type. For call and put options,
the %OTM is preceded by a lowercase "o
" and the number of
months out is preceded by a lowercase "m
".
Crystal Ball
CB ss [...] [#] [s
]
First, one or more screen codes, followed by the limit of stocks to
select, if any. The code "s
" indicates a seasonal crystal ball.
Movers
MV ss # # [l
#]
First, the screen code, followed by the ranks to consider. If there's
limit of stocks to select, it's preceded by a lowercase "l
".
Relative Strength of Screens
RS ss [...] [# #] (s
| x
) #
First, the screen codes are listed for all screens compared. Next are
the ranks to buy/compare (unless the screens are backtest codes, in which
case all ranks are used), then an "s
" for "seasonal" lookbacks
or an "x
" for regular lookbacks, followed by the number of
years or periods to look back.
Freshmen Overlap
FR ss ss # # [o
# #] [l
#]
First, the screen codes for the two screens to overlap, and the ranks to
consider for the freshmen test in the Standard format. Next comes the
ranks to use for the overlap, preceded by a lowercase "o
".
If there's a limit of stocks to select, it's preceded by a lowercase
"l
".
Occasional Overlap
OO ss ss [f
] [s
] # # [l
#] ...
For each overlap to try, the following:
First, the screen codes for the two screens to overlap. A lowercase
"f
" for a freshmen overlap, and a lowercase "s
"
to pick the second overlapped stock. Then come the ranks to overlap in
Standard format (the f
and s
option must
precede this). If there's a limit of stocks to select, it's preceded by
a lowercase "l
".
Using the above, you can decode the backtest code
"My~~Screen:0316vRS(HD(FCF-26)(SS(Microcap_Momentum)(Net-Nets_Grahamified)10m10)12s10)(ST(Small_Value)12)x1
":
My~~Screen:
- Named "My Screen"
03
- From 2003
16
- To 2016
v
- List picked stocks
RS
- Use the Relative Strength of Screens tester
(HD(FCF-26)(SS(Microcap_Momentum)(Net-Nets_Grahamified)10m10)12s10)
-
Run the Hold-'Til-Drop tester with the code
"
(FCF-26)(SS(Microcap_Momentum)(Net-Nets_Grahamified)10m10)12s10
":(FCF-26)
- The HTD "buy" screen is FCF-26.
(SS(Microcap_Momentum)(Net-Nets_Grahamified)10m10)
-
The HTD "transition" screen is from the SOS tester with the code
"
(Microcap_Momentum)(Net-Nets_Grahamified)10m10
":(Microcap_Momentum)
- Microcap_Momentum
(Net-Nets_Grahamified)
- Net-Nets_Grahamified
10
- 10 positions per screen
m10
- Max score 10
12
- Buy positions 1-2 in the "buy" screen.
s10
- Sell when below 10 on the "buy" screen and off the "transition" screen.
(ST(Small_Value)12)
-
Run the Standard tester with the code "
(Small_Value)12
", which is Small_Value 1-2. x1
- Non seasonal, 1 period look-back.
Nothing to it, really :-).