The ULTRA
Signal File Optimizer
User's Guide
Copyright ULTRA Financial Systems Inc. (C) 2004, All Rights Reserved. (
The ULTRA Signal File Optimizer (SFO).
The
SFO allows you to automate the process of developing composite timing
strategies. The SFO can be used for many
reasons.
1. Automating the process of developing Composite Strategies.
It is possible to spend a lot of time testing various combinations of systems. The SFO automates that process making the strategy that has
performed “best” historically very easy to identify.
2. Create optimal strategies over specific time periods.
For example, you may think the market's future is going to be similar to the
Bear Market of Jan74 to Oct74. You may
want to create a mechanical strategy for trading the SP500 short. The SFO would allow you to easily develop
that short strategy by optimizing over the 1974 historical period.
3. Testing all the possible combinations that are similar to the one you
are considering.
The reason you would want to perform this type of analysis is to make sure that
the excellent back-tested history of your strategy is not just random. If all combinations of weightings and
allocations similar to the set you've selected are profitable, then the chances
of your particular set being randomly profitable are minimal.
4. Checking to see if a particular system adds value to your strategy.
With the SFO, you can simply run an optimization with a weight of zero as one
of the possibilities for each system.
This will allow you to easily identify systems that add to the
historical performance of your Composite Strategy.
The
SFO logic may seem complicated at first glance but it's really not bad once you
get the concepts down. Putting
everything into words makes it seem more complicated than it really is.
Here's how the SFO Works:
The
SFO operates on a Composite Optimization Definition File (CODF). A CODF can be created using Microsoft
Notepad, which can be accessed, via the ULTRA's
File\New menu item. The CODF is similar
to standard ULTRA composite files with some important differences.
Below
is an example of a simple CODF. You can create a CODF via ULTRA's
File\New menu item. For your convenience
this file is already located in your \ultra8 folder named, S_TEST.
@SYS
yroc.sig,0 to 4 by 1 *ND
vol.sig,0 to 4 by 1 *ND
pent.sig,0 to 4 by 1 *ND
lhd2s.sig,0 to 4 by 1 *ND
@ALLP
30,0 50,50 100,100
50,0 70,50 100,100
70,0 90,50 100,100
@END
Bottom of Page 2
The @SYS section.
The
CODF uses signal files that represent the systems to be included. The use of signal files is what allows the
SFO to test combinations so quickly. In
this example, four signal files are used which are listed in the @SYS section.
The
line:
yroc.sig,0 to 4 by 1 *ND
is of the form
signalfile,W0 to Wn by INC *ND
Where:
Signalfile = Name of the signal file
located in the \ultra8 folder. These
files can be FastTrack or Monocle format.
But don't mix them. Use ALL
FastTrack files or ALL Monocle files.
W0 =
the beginning weight. (Only integer weights are allowed. I.e. 1.5
is illegal)
Wn = the ending weight.
Inc =
the amount to increment.
*ND = The "Next Day"
switch. (Optional. This will delay the signal file's signal by
one day causing the system represented by the signal file to be treated as a
NEXT-DAY system. See below for more
information.)
This
line will cause the SFO to test YROC.SIG with weights 0,1,2,3, and 4.
In
the example above, the SFO will test every combination of the weightings 0-4
for the four systems represented by signal files. The number of combination can
be computed by the following formula:
C =
W1 * W2 * W3 *W4.
Where:
C = total
number of combinations.
W1 = number of weights for system 1.
W2 = number of weights for system 2.
W3 = number of weights for system 3.
W4 = number of weights for system 4.
In
the example above there would be 625 combinations of weights (C= 5*5*5*5=625).
This is important because the number of combinations grows exponentially as you
add systems, weights, and allocation sets.
Zero and Negative Weightings
A
zero weighting basically ignores that particular system in that combination.
A
negative weighting will subtract from the total when the system is on a buy
signal. You could create signal files that generate "buy" signals
upon very negative circumstances and then give the signal file a negative range
of weightings.
The *ND switch
You
can indicate in your CODF that a signal file should be traded "Next Day"
regardless of what is selected when you actually optimize the CODF.
Bottom of Page 3
For
example, suppose you want to test YROC.SIG as "Next Day" and
SEAS2.SIG as "Same Day".
Here's how:
1. Create "Same Day"
signal files for both YROC.SIG and SEAS2.SIG.
2. In your CODF enter the
lines:
YROC.SIG, 1 to 3 by 1 *ND
SEAS2.sig, 1 to 3 by 1
3. Optimize your CODF as
"Same Day".
The
*ND switch forces YROC.SIG to be traded "Next Day".
The
*ND switch allows you to model any combination of "Same Day" and
"Next Day" signal files while only maintaining physical "Same
Day" signal files. I.e. All the signal files you generate with ULTRA or enter
manually are "Same Day" signal files.
The *ND switch tells SFO to treat them as "Next Day".
Note:
If
the above example were optimized as "Next Day", both YROC.SIG and
SEAS2.sig would be traded as "Next Day". The *ND would be ignored. YROC.SIG would not be traded two days later.
The @ALLP section.
The
@ALLP section is similar to the @ALL section in standard ULTRA composite files
except that it uses percentages instead of fixed point values. [The 'P' stands
for (P)ercentages]. This is necessary because the
total number of points changes. (I.e. in the example above the first
combination, 1,1,1,1 will have point total of four. Whereas, another
combination, 2,5,3,1 will have a point total of 11. (Note: When all systems are
weighted zero the results are obviously not meaningful.)
Each
line is a separate Allocation Set.
Every combination of systems will be tested against each Allocation Set. In the
example above there are 625 combinations of system weights. Those 625
combinations will be run against each of the three Allocations Sets in the
@ALLP section.
Each
pair in the allocation set is of the form (P%, I%)
where:
P% = The number of points divided by the total
possible points. In the example above, during the first combination the weights
will be 1,1,1,1 for a possible total of four. If only YROC.SIG is on a buy
signal, P% = 1/4 = 0.25 = 25%.
I%= Percent Invested. 50= 50% long. 0 = 100% cash. -100 = 100% short.
Therefore,
30,0 50,50 100,100 means:
0%
invested if: P% <= 30% of the total possible.
50% invested if: 30% < P% <= 50% of the total possible.
100% invested if: P% > 50% of the total possible.
A
good way to visualize this is to think of it as:
0-30,0 31-50,50 51-100,100 (I.e.
When P is 0 to 30 then 0% long).
For
example, if the SFO were testing weights, YROC.SIG=3, VOL.SIG=4, PENTAD.SIG=1,
and LHD2S=1, and only YROC.SIG was on a buy signal, P would be 3. The total
possible would be 9 and so P% would be 3/9=0.333=33%. Therefore, the composite would be 50%
invested.
Bottom of Page 4
Total number of combinations.
Since
there are 625 total combinations of system weights and three allocation sets,
the total number of combinations is C = 625 * 3 = 1875.
C =
W1 * ... * Wn * A.
Where:
W1 =
First system combinations.
Wn = Last system combinations.
... = All the system combinations between W1 and Wn.
A = Number of allocation sets.
Setting up the Optimization
The
SFO is able to test composite combinations very quickly because it uses only
signal files. However, there is a
tradeoff for this speed. That is, there
is some setup that is necessary before running composite optimizations.
1. Build all the signal files for ULTRA internal systems.
In ULTRA,
go to \Options\Signal File Options and select "FastTrack
Format". Make sure that
"Create NEXT-DAY Signal Files" and "Create four digit
years" are NOT checked.
Next, run a Timing/Historical Analysis from the
earliest possible day (Start date =
2. Create the Data file.
Data files can be created with ULTRA's
Data/Export Data menu item. After
selecting, change the following fields and leave the rest unchanged:
Start Date:
Export File Name: SP500.dat
You can obtain complete details on ULTRA's Data/Export Data by clicking on the HELP
button.
We recommend that you export from ULTRA in the
format: DATE,SP500
(default). If you export in another format you must make sure that you change the
format the SFO expects in \Options\External Data File Options.
Now
all of the necessary files should be constructed and ready for use by the
SFO. The following files should all be
located in your \ultra7 folder:
s_test.txt, yroc.sig, vol.sig, pentad.sig, lhd2s.sig, and sp500.dat.
If
any are missing you have made an error.
Bottom of Page 5
The Optimization
You start the optimization by selecting: SFO/Optimize Composite.
1. First select the CODF file
you want to optimize: s_test.txt and
click OK.
2. Select the data file: sp500.dat and click OK.
3. On the next screen be sure
to select SAME-DAY. Remember we have
handled the NEXT-DAY aspect using the *ND flag.
4. Leave everything else as is
and click OK. You can click on HELP to
get detailed information on all the options available on this screen.
5. In the final dialog box,
click on OK and the optimization will begin.
When the optimization is complete, a file named
SFO.DMP is created and displayed that contains the results. If you want to save
the file under another name for future reference, you can via the File/Save As
menu item.
C:\ULTRA8\S_TEST.
@SYS
yroc.sig,0 to
4 by 1 *ND
vol.sig,0 to
4 by 1 *ND
pent.sig,0 to
4 by 1 *ND
lhd2s.sig,0
to 4 by 1 *ND
@
30,0 50,50
100,100
50,0 70,50
100,100
70,0 90,50 100,100
@END
---------------------------------------------------------------------
Start Date:
End Date:
Trade Same Day. Long Beta=1.00 Short Beta=1.00
Data File = C:\ULTRA8\SP500.DAT
Cash at 5.00%
Buy/Hold Data File:
(1)-Allocations: Buy = 30,0 50,50
100,100 Sell = 30,0 50,50 100,100
(2)-Allocations: Buy = 50,0 70,50
100,100 Sell = 50,0 70,50 100,100
(3)-Allocations: Buy = 70,0 90,50
100,100 Sell = 70,0 90,50 100,100
---------------------------------------------------------------------
---------------------------------------------------------------------
(1)
0, 0, 0, 0=> +3.25 +0.00
0.0 +0.0 +0.0
0.0
(1)
1, 0, 0, 0=>
+13.05 +19.61 56.4
-19.7 +3.9 2.3
(1)
2, 0, 0, 0=>
+13.05 +19.61 56.4
-19.7 +3.9 2.3
<Remaining 1,873 combinations have been
deleted>
Bottom of Page 6
The
first section is an echo of the Composite Optimization Definition File (CODF).
The
second section contains details about the optimization. Where:
CARWI = Compounded Annual Return While Invested.
PI = Percent Invested
MDD= Maximum Drawdown.
UI= Ulcer Index.
(1) = The first allocation set.
(2)= The second allocation set.
The
third section is the combination's results.
Since these results have not been sorted, the few combinations listed
are in the order that the SFO tested them. .
An explanation of the listing is below:
(1) 2, 0, 0, 0 = (1) indicates the
FIRST allocation set. The 2, 0, 0, 0
indicates the system weights of:
YROC.SIG=2, VOL.SIG=0, PENTAD.SIG=0, LHD2S.SIG=0.
Notes:
·
ULCER Index Formula (UI in the SFO.DMP file.)
DD = drawdown
for a single day.
SUM = summation
of DD2 for all days in the analysis.
DAYS = Total
number of days in the analysis.
ULCER Index = The square
root of (SUM/DAYS).
·
The sfo.dmp file can be extremely large. We have tested a file that is 5 Meg in size
and it worked perfectly in Windows Wordpad. (The SFO will attempt to open the file with
Windows Notepad. If the file is too
large for Notepad, Windows will use Wordpad
instead.)
·
When a composite is in cash the account appreciates at an annual rate
that is selectable by the user. This example uses 5%.
Sorting.
Sorting
is very important because some of these optimizations may involve tens of
thousands of combinations. You can sort on any of the performance statistics.
You
sort by selecting: SFO/Sort. You will be asked for the file name, which
will usually be sfo.dmp, unless you have renamed an
old sfo.dmp to another name. Select SFO.DMP and click OK. You will then be asked for the Column number
on which to sort. The possible column
numbers will be listed on the screen.
These values are dependent on the contents of the file to be
sorted. Press OK to start the sort.
Bottom of Page 7
Generating Allocation Sets
In
the example above we used a simple set of allocations in the @ALLP section.
30,0 50,50
100,100
50,0 70,50 100,100
70,0 90,50 100,100
This @ALLP section tested Percent Invested values (0, 50, 100) with the first Percent Invested change starting at a Percentage of 30% (30,0 in the first line) and the last Percent Invested change happening at
90% (90,50) in the last line.
Remember: The line 30,0 50,50 means that the strategy will:
Go 0% long if the Percentage of points on buy signals is
0% to 30%
Go 50% long if the Percentage of points on buy signals is
31% to 50%
Assume you want to test more Percent Invested values such as -100, -50, 0, 50, 100.
Further
assume you want to test a wide range of allocations with the first change
occurring when 10% of points are on buy signals and the last change occurring
at 90%.
Generating this @ALLP section manually can be difficult.
Using the SFO menu item Generate Allocations Sets, you can create this @ALLP section easily
by typing into the fields as displayed below.

The
Resolution field is the spacing between Percentages
that cause the strategy to change Percent
Invested. In this example, the first
allocation set generated will be:
10,-100 15,-50 20,0 25,50 30,100 (See the @ALLP Section above for
details about this format)
As
you can see the Percentages increase by the Resolution (10, 15,
20, 25, 30)
Generate Allocations Sets will generate all the
combinations of allocations and display them with Windows’ Notepad. From there you can Edit/Select All and Copy. Then
you can paste these values into your @ALLP section.
Remember: The number of Allocation Sets grows the Total
Combinations exponentially. Review the
@ALLP section above for computing the Total Combinations.
Bottom of Page 8
The Sorted Optimization Results.
When the optimization/sort is
complete, a file named SFO.DMP is created and displayed that contains the
results. If you want to save the file under another name for future reference,
you can via the File/Save As menu item. For example: (Note:
This example sfo.dmp has been sorted on CAR.)
C:\ULTRA8\S_TEST.
@SYS
yroc.sig,0 to
4 by 1 *ND
vol.sig,0 to
4 by 1 *ND
pent.sig,0 to
4 by 1 *ND
lhd2s.sig,0
to 4 by 1 *ND
@
30,0 50,50
100,100
50,0 70,50
100,100
70,0 90,50
100,100
@END
---------------------------------------------------------------------
Start Date:
End Date:
Trade Same Day. Long Beta=1.00 Short Beta=1.00
Data File = C:\ULTRA8\SP500.DAT
Cash at 5.00%
Buy/Hold Data File:
(1)-Allocations: Buy = 30,0 50,50
100,100 Sell = 30,0 50,50 100,100
(2)-Allocations: Buy = 50,0 70,50
100,100 Sell = 50,0 70,50 100,100
(3)-Allocations: Buy = 70,0 90,50
100,100 Sell = 70,0 90,50 100,100
---------------------------------------------------------------------
---------------------------------------------------------------------
(1)
3, 3, 1, 4=>
+15.77 +21.04 68.4
-10.9 +3.6 20.7
(1)
2, 2, 1, 2=>
+15.65 +23.08 60.5
-10.8 +3.2 14.3
(1)
3, 3, 1, 3=>
+15.65 +23.08 60.5
-10.8 +3.2 14.3
(and so on)
As
you can see above the optimal combination out of the 1875 combinations tested
is:
Allocations: 30,0 50,50,
100,100
Weights: YROC=3,
VOL=3, PENTAD=1, LHD2S=4
Bottom of Page 9
Converting a CODF Combination to an ULTRA Composite.
In the example above, the
optimal combination was:
Allocations: 30,0 50,50, 100,100
Weights: YROC=3,
VOL=3, PENTAD=1, LHD2S=4
Computing Maximum Total Points
The
four systems have a potential Maximum
Total Points of 11,
(3+3+1+4=11).
Converting % Allocations to
ULTRA type Allocations
1. Select "SFO/Convert % Allocations to Point
Allocations" from the SFO menu.
2.
Enter the CODF
allocations and the Maximum Total Points
in the fields provided. In our example
the fields would contain:
Enter
the SFO's CODF percentage allocations: 30,0 50,50 100,100
Enter the Maximum Total Points: 11
3. Press the OK button to start the conversion.
Note: Make
sure there are not any blanks before or after the comma.
(I.e. 59 , -100 is incorrect. 59,-100 is correct.)
The
output of this conversion is a displayed temporary file. In our example that file would contain:
3,0
5,50
11,100
From
this file you can copy the text and paste into an ULTRA composite definition
file. To do this select all the text in
the window and select Edit/Copy then Exit.
Now
the text is located on the Windows Clipboard ready to paste into any other .txt
file.
The final
conversion to ULTRA Composite Format.
@SYS
YROC,3
VOL,3
PENTAD,1
LHD2S,4
@ALL
3,0
5,50
11,100
@END
The @ALL format is covered in
the ULTRA User's Guide in the "Composite Systems" section. Briefly, the lines mean:
Bottom of Page 10
3,0
=> If the composite strategy's total points is 0,1,2,3, then take a 0% long
position.
5,50 => If the composite strategy's total points is
4,5, then take a 50% long position.
11,100 => If the composite strategy's total points
is 6+, then take a 100% long position.
Recall that the percentage
allocations used by the SFO called for:
0-30% => 0% long
31-50% => 50% long
51-100% => 100% long
As you can see the above allocations in the @ALL
section represent the same allocations as the optimal SFO combination.
Dump Files.
There is a series of files that
are created when an SFO Composite Optimization is performed. These are mainly for our debug purposes but
they may be of interest to users also.
SFO_ONE.DMP-This is a trade-by-trade analysis of the first
combination in the Composite Optimization.
You can get a trade-by-trade analysis for any combination by modifying
the CODF to force a specific combination to be the first (or only) in the
optimization.
SYS_SIGS.DB- This is a
listing by date of all the statuses of the signal files used in the composite.
SW_SIGS.DB- This is a listing by date of the status of the SSF.
Bottom of Page 11
@BALP/@SALP logic can also be used.
Assume the following example:
@BALP
30,0 50,50 100,100
50,0 70,50 100,100
@SALP
20,0 40,50 100,100
40,0 60,50 100,100
@END
The allocations work exactly
the same as the @ALLP example except that @BALP allocations are used when the
point total (P) is rising (i.e. P on the curent day
is higher than the previous day.) The
@SALP allocations are used when P is falling. The lines in each section match
up. The first BALP/SALP allocations
will use line 1 of each section, and so on.
In this example, the SALP
allocations make it a little harder to sell to cash. You can see that the first
line in the BALP section takes a 50% invested position when P is 50% of the
total. In the SALP first line the allocation doesn't drop to 50% invested until
P is less than 40% of the total. (For a
complete description of the BALP/SALP functionality see
the ULTRA User's Guide).
Bottom of Page 12 <end>