System optimization consists in launching multiple system tests or STOP commands, each time changing one or several parameters.
The system tutorial presents examples of optimizations where the most efficient average of the sample system was set.
In that example, the objective was to obtain optimized data ranging from 10-50 periods, with 5-period steps.
Every system can feature up to 10 optimizable variables (marked consecutively from OPT1 to OPT10).
Those variables cannot be used in user indicators. In order to perform an optimization, replace selected system or STOP command
parameters with relevant "OPT" variables and then specify the range of values for desired parameters and step of the search.
During the optimization, Metastock will perform a specific number of tests trying all possible combinations in the defined range.
The number of tests performed by the system will be displayed under "Total Tests" in the "Optimization Variables" window.
The number of tests may not exceed 32,000.
See below for an example of an "OPT" variable used in the system syntax - in this case "opt1" changes parameter
"time" in the average function.
C> Mov(C,opt1,E)
The "OPT" variable used for STOPs is placed directly in the "Parameter" field of the STOP window.
Now specify the "OPT" range (minimum, maximum, step). When testing a system that features OPTs Metastock will
automatically perform all tests for all possible combinations of variable.
Defining Optimization Variables
To define the range of optimization of system or STOP command rules, click on "Optimize" in the "System Editor" or "Stops" window.
New:
Adds a new variable to lets the user edit its contents.
Edit:
Lets the user edit the contents of a variable (minimum, maximum and step).
Delete:
Deletes the selected variable. You cannot delete a variable which is used by
any of the system rules.
Total Tests:
Display the total number of tests to be conducted.
Example of optimization
This rule opens a long position if the closing price exceeds the 10-period average:
Enter Long:
CLOSE> mov(CLOSE, 10, SIMPLE)
If you are not sure whether this is the optimum lenght, you can replace it with
an OPT variable.
Replace "10" in the above formula as shown below:
Enter Long:
CLOSE> mov(CLOSE, OPT1, SIMPLE)
The OPT1 range (e.g. from 5 to 20 with a step of 5) is defined in the "Optimize" window
of the System Editor.
During testing, Metastock will perform several tests of the system, applying subsequent values in system rules,
as shown below.
Enter Long:
CLOSE> mov(CLOSE, 5, SIMPLE){Test #1)
Enter Long:
CLOSE> mov(CLOSE, 10, SIMPLE){Test #2)
Enter Long:
CLOSE> mov(CLOSE, 15, SIMPLE){Test #3)
Enter Long:
CLOSE> mov(CLOSE, 20, SIMPLE)
{Test #4)
After the system has been tested, Metastock will generate four reports (one for each optimized value).
The following example illustrates the use of several "OPT" variables:
Enter Long:
rsi(14)> OPT1
Close Long:
rsi(14)
Enter Short :
rsi(14)
Close Short:
rsi(14)> OPT1
OPT1:
minimum = 20, maximum = 40, step = 10 {3 tests}
OPT2:
minimum = 70, maximum = 80, step = 10 {2 tests}
In the above example, OPT1 has three possible values
(20, 30 and 40), OPT2 has two possible values (70 and 80).
This combination requires 6 tests (3 * 2):
Test # OPT1 OPT2
1 20
70
  2 30
70
3 40
70
4 20
80
5 30
80
6 40
80
Back