As mentioned earlier in this document, Mechanica was designed from the ground up to allow you to test multiple systems across multiple portfolios at the same time. Simultest mode makes it possible.
|•||You can simultaneously test System 1 and System 2 on Portfolio A. |
|•||You can just as easily test System 1 on Portfolio A (consisting of a basket of futures, for instance), and simultaneously test System 2 on Portfolio B (which might consist of a basket of stocks). |
|•||If, for example, you want to test a single system on both futures and stocks simultaneously, this is easily accomplished: Set up one portfolio consisting of all the futures you want to trade, and another consisting solely of stocks. First, test System 1 on the futures portfolio. Then turn Simultest on, change the Data Page, and test System 1 on the stock portfolio. (We’ll go over this process in greater detail in the following section).|
After running multiple systems (Signal Rules files) in Simultest mode, it’s time to run the Position Sizing Rules. At this stage, you can easily develop and apply unique position sizing and resizing strategies to each system, and see how they behave in dynamic interaction.
The point of all this? Simple. To take advantage of diversification, which has been called, “the only free lunch on Wall Street.” The goal is to employ multiple, uncorrelated systems in order to enhance performance, control volatility, and achieve maximum profitability in alignment with your risk objectives. Mechanica’s Simultest feature helps you determine the best way to do just that.
In Simultest mode, multiple Signal Rules files are run, one after the other, and each system’s trades are stored in a composite trade database, along with a unique system identifier. These trades will later be accessed by the Position Sizing Rules, with full knowledge of which trades were generated by which system.
So strictly speaking, Simultest begins as a serial operation that is conducted on the Signal Rules side. But it is the Position Sizing Rules that truly make the Simul part of Simultest come to life, by giving you the ability to uniquely size and resize all trades from all your systems together at the same time, one trading day at a time.
Remember: running a simulation in Mechanica is always a two-step process, and Simultest mode is no different in that regard. The Signal Rules files are run first, to generate trades. Then, the Position Sizing Rules are run. In Simultest mode, the difference is that multiple Signal Rules files are run, one after the other, prior to running the Position Sizing Rules.
Of course, once the Signal Rules have been run and trades have been generated for a system—or for multiple systems, using Simultest mode as we did here—you are free to experiment with various Initial Sizing and Resizing strategies, without having to re-run the Signal Rules.
Although it is counterintuitive, the way to start a Simultest run is with the Simultest setting turned Off. Otherwise, you may inadvertently wind up including trades that were generated by your previous Signal Rules run. (Since Mechanica’s default state for Simultest is Off, this generally won’t be an issue. But it’s an important point to comprehend).
If this doesn’t make sense at first, understand that Mechanica writes all trades to a trade database, and they remain there even after you exit the application.
Let’s say you ran Breakout.sig Monday night, for example, then exited Mechanica and turned off your PC. The next morning, you boot your PC and launch Mechanica. Whether you realize it or not, the trades generated the previous night by Breakout.sig are still sitting in the trade database, at your disposal. You could then open a SIZ file, run it, and see the same PSR as before without having to run any SIG code at all.
Thus, if you start a Simultest run with Simultest turned On, and answer “Yes” to the prompt, “Continue with SIMULTEST?” ...then you will include all trades generated by the previous Signal Rules run, whether you meant to or not.
You will generally want to overwrite the existing trades in the trade database when you start a Simultest run. You do this by running your first Signal Rules file with Simultest Off.
|•||With Simultest Off, the trades in the trade database are overwritten every time a new Signal Rules file is run.|
|•||With Simultest On, Mechanica keeps accumulating trades in the trade database until you (a) stop running new Signal Rules files, or (b) until you turn Simultest Off.|
To run a SIMULTEST
The step-by-step instructions below should prepare you to run any Simultest scenario you can imagine.
|32||Verify that you are not already in Simultest mode (choose Simultest Off, under the Signals menu).|
|33||Open the first Signal Rules file (the first system) that you wish to include in your Simultest. |
|34||In the Rules Editor, on the Resources page of this Signal Rules file, make certain that you assign a unique value to the SYSTEM variable, as shown in the graphic below. |
|•||The SYSTEM keyword is specifically intended for use in Simultest. Its use is enforced because the value assigned to the SYSTEM keyword will later be used by the Position Sizing Rules to associate each trade with the system (Signal Rules file) that generated it.|
|35||Choose the first portfolio of instruments you wish to test by selecting the desired Data Page (choose Symbol Manager under the Data menu). |
|•||Only the Pinnacle Futures Data Page is created during the Mechanica install. The other (three) Data Pages were created for the sake of illustration.|
|36||Close the Symbol Manager.|
|37||Click the Run arrow on the Signal toolbar to run the first Signal Rules file. |
|38||Turn Simultest ON (choose Simultest On, under the Signals menu). |
|39||At this point, you can leave Simultest ON until you have tested all the systems you wish to Simultest.|
|40||It’s a good idea to get into the habit of turning Simultest ON immediately after the first Signal Rules run is complete, so that you do not inadvertently overwrite it by leaving Simultest OFF (in which case you will be forced to start over).|
|41||Open the next Signal Rules file you want to include in the Simultest. |
|42||In the Rules Editor, on the Resources page of this Signal Rules file, make certain that you assign a unique value to the SYSTEM variable (as we did earlier in this exercise). |
|43||Now, choose the portfolio of instruments that you wish to test the second system on, by selecting the desired Data Page (choose Symbol Manager under the Data menu). |
|•||You may well want to test multiple systems on the same portfolio of instruments. If that is the case, then simply omit the previous step and do not select a new Data Page.|
|44||Close the Symbol Manager.|
|45||Click the Run arrow on the Signal toolbar to run the second system.|
|46||You will be prompted with a dialog box asking you to confirm your decision to “Continue with SIMULTEST?” Click “Yes” to continue.|
|47||Repeat this process with as many systems as you wish to test.|
|48||When the last Signal Rules file has been run, you are free to run the Position Sizing Rules (Alt–R, P). To try a different position sizing strategy, just open and run another SIZ file, or modify the current one.|
During Simultest, if you make the mistake of running two different Signal Rules files with identical SYSTEM keyword values on the same instrument (or more likely, on the same Data Page), Mechanica will issue the following error. It is very clear in its message: Duplicate trades from the same system are not allowed.
To address multiple systems from a single SIZ file
In Simultest mode, even though there are potentially thousands of trades from numerous different systems sitting in the trade database, in general you will not run more than one Position Sizing Rules file per Simultest session.
If that’s the case, then how do you go about applying a unique sizing strategy to each system? Simple: by referencing the unique value of each system’s SYSTEM keyword (defined on the Resources page of each Signal Rules file).
The SYSTEM keyword was specifically intended for use in Simultest, and every trade in the trade database carries this unique SYSTEM identifier. Thanks to its presence, the Position Sizing Rules are able to associate each trade with the system that generated it.
The example below assumes a Simultest of three different systems, and demonstrates how the SYSTEM keyword can be used to apply a unique Initial Sizing strategy to each system. Of course, the same method can also be employed on the Resize page.
MEMORY = (TOTALEQUITY * .005) * SIZING
MEMORY = (TOTALEQUITY * .0075) * SIZING
MEMORY = (TOTALCLOSEDEQUITY * .01) * SIZING
IF SYSTEM = 1 AND SYSTEMPOSITIONS < 30 THEN NEWCONTRACTS = MEMORY
IF SYSTEM = 2 AND SECTORPOSITIONS < 4 THEN NEWCONTRACTS = MEMORY
IF SYSTEM = 3 AND TOTALONGLOSERS < 2 THEN NEWCONTRACTS = MEMORY
|1.||The SYSTEM keyword, which is used to discretely identify each system, has a valid range of 1 to 254. So in theory, it is possible to conduct a Simultest of 254 different trading systems, each trading its own portfolio.|
|2.||Although it’s possible to mix futures and stocks on the same Data Page (i.e. within the same portfolio), it is a good practice to create separate Data Pages for each.|
Introduction to Batch files
Batch Files are designed to automate tasks. Conceptually, a batch file is nothing more than a list of processing instructions for Mechanica to follow, which it does, line-by-line. Before demonstrating how to automate a Simultest run using a batch file, here’s what you need to know about them:
|1||To create a batch file, open a new Signal Rules file.|
|2||Name the file. Mechanica identifies any Signal Rules file with the word "batch" in the filename as a legitimate batch file. An example of this would be, My_Batch.sig. Batch files can reside in any directory.|
|3||Place all batch file instructions on the Resources page.|
|4||Execute the batch file just like a Signal Rules file; click the Run arrow on the tool bar, or choose Run Signal Rules (Signals menu).|
|•||Batch files are processed line-by-line; there can only be one statement per line. |
|•||Numerous Mechanica Basic keywords can be executed from within a batch file. See indented topics under Batch file-related. |
|•||Other instructions that can appear in a batch file are SIG filenames and SIZ filenames including path. So if Mechanica sees c:\SizStuff\MyFavorite.siz within a batch file, it knows to execute this Position Sizing Rules file. |
|•||Unless the path is specified, files called from within a batch file must reside in the directory ?\My Documents\Mechanica...|
To automate a SIMULTEST using a Batch file
The example batch file below demonstrates how to automate the running of a Simultest. It concludes by launching and running a Position Sizing Rules file. Line numbers were added to facilitate discussion only. Do not place line numbers in your batch file!
|•||Just as we did with the manual Simultests earlier in this section, the first line of the batch file ensures that Simultest is turned off (simultest=off).|
|•||In line 2, the keyword dpage tells Mechanica the name of the Data Page you want to use. In this case, it is “currencies”.|
Note You should specify the target Data Page, using the dpage keyword, at least once. Otherwise Mechanica would use the Data Page(s) that are currently tagged. You may specify a different one for each system you intend to run from a batch file. If mutliple systems all use the same Data Page, then it is only necessary to set the Data Page once, prior to calling your first .SIG file.
|•||Line 3 instructs Mechanica to open and run the Signal Rules file named Long_Term_Trend.sig. |
|•||Line 4 is pretty obvious. It turns Simultest On. Line 5 instructs Mechanica to switch the active Data Page from “currencies” to “stock_indexes”. |
|•||Line 6 instructs Mechanica to open and run the Signal Rules file named CounterTrend.sig, which is located in the directory named Newsystems. Remember - unless a path is specified, files called from within a batch file must reside in the directory ?\My Documents\Mechanica...|
Now that two Signal Rules files have been run on two separate Data Pages...
|•||Line 8 instructs Mechanica to open and run the Position Sizing Rules file named My_Siz_File.siz (on the two systems that we Simultested: Long_Term_Trend.sig, and CounterTrend.sig).|
|•||The nextstep keyword must always be placed immediately before the statement that executes the last Position Sizing Rules file called.|
Provided that your syntax is correct, and that any SIG and SIZ files you reference (a) exist and (b) reside in ?\My Documents\Mechanica...,or in the directory you specified, then when you click the Run arrow on the Signal toolbar, your batch file should run flawlessly.
The message below will appear upon successful execution.
To run a SIMULTEST (summary)
For your convenience, the following is a stripped down version of the steps we went through earlier in this section.
|1||Verify that Simultest is OFF.|
|2||Open the first Signal Rules file you wish to test.|
|3||Ensure that the System variable (for this Signal Rules file) is assigned a unique value on the Resources page.|
|4||Select the desired Data Page for the first system you wish to test.|
|5||Close the Symbol Manager.|
|6||Click the Run arrow on the Signal toolbar to run the first system.|
|7||Turn Simultest ON (and leave it on until you are done).|
|8||Open the next Signal Rules file you wish to test.|
|9||Ensure that the System variable (for this Signal Rules file) has been assigned a unique value on the Resources page.|
|10||Select the desired Data Page for the second system you wish to test. (Omit this step if you want to test multiple systems on the same portfolio of instruments).|
|11||Close the Symbol Manager.|
|12||Run the second system (Signal Rules file).|
|13||Press “Yes” to continue when you are prompted with the “Continue with Simultest?” dialog box. |
|14||Repeat this process with as many systems as you wish to test.|
|15||Run the Position Sizing Rules.|
|•||To try a different position sizing strategy, just open and run another SIZ file, or modify the current one|