MSA3 Users Guide
MSA3 Users Guide
MSA3 Users Guide
Version 3
User's Guide
This software is protected by copyright and intellectual property laws, including international
laws and agreements. This software is licensed, not sold. The terms of this license agreement
include the following:
1. The software may be freely distributed provided the installation executable is unaltered
and distributed in whole.
2. A single license may allow operation of the software only on the computer on which it is
originally installed. To install the licensed version on more than one computer or to
install it on a different computer, please contact Adaptrade Software for additional
activation codes. Additional codes are generally free of charge for reasonable use.
Regardless of how many copies are installed, a single license grants you the right to use
only one copy at a time.
3. This license agreement is not transferable.
4. You agree not to hold Adaptrade Software liable for any losses or damages resulting
from the use of this software.
5. You agree not to reverse engineer or “decompile” any part or component of the
software.
6. The software is provided “as is.” While Adaptrade Software makes every effort to
provide reliable software, free of defects, omissions, and errors, there is no guarantee
that such defects, omissions and errors are not present in the software. You accept sole
responsibility for verifying any calculations made by the software.
iii
Table of Contents
Disclaimer .............................................................................................................................................................i
Introduction ......................................................................................................................................................... 9
Overview .......................................................................................................................................................... 9
Installation ..................................................................................................................................................... 10
Market Systems and Portfolios ....................................................................................................................... 11
Understanding the Document Windows ......................................................................................................... 11
Program Conventions .................................................................................................................................... 13
Data Requirements ......................................................................................................................................... 14
Examples ........................................................................................................................................................ 15
Fixed Fractional............................................................................................................................................. 44
Optimal f......................................................................................................................................................... 44
Profit Risk Method ......................................................................................................................................... 45
Fixed Ratio ..................................................................................................................................................... 45
Generalized Ratio ........................................................................................................................................... 46
Margin Target ................................................................................................................................................ 47
Leverage Target ............................................................................................................................................. 48
Percent of Equity ............................................................................................................................................ 48
Max Drawdown Method ................................................................................................................................. 48
Maximum Possible ......................................................................................................................................... 49
Equity Curve Crossovers ................................................................................................................................ 49
Real Time Position Sizing............................................................................................................................... 50
Appendix: Position Sizing Code for TradeStation and MultiCharts .......................................................... 111
The following steps outline the basic process of using Market System Analyzer (MSA) 3:
1. Compile the trade data for the market system(s) you wish to analyze into one or
more text files.
2. Select the file(s) of trade data compiled in step 1.
3. Enter basic settings, such as whether the input data represent stocks or futures,
starting account equity, margin, commissions, etc.
4. Choose a position sizing method.
5. Explore optional methods and analyses, such as dependency rules and equity curve
crossover rules.
6. Adjust the position sizing settings and rules to maximize trading performance.
7. Use the Trade Size command for real-time position sizing if desired.
8. Optionally create a portfolio by selecting two or more market-system files.
Step 1
MSA supports two basic text file formats: RINA xml files and text files in which the trades
are arranged one trade per line with separate fields on each line for the different elements of
each trade. RINA xml files can be saved from the performance reports of various trading
programs, such as MultiCharts and TradeStation.
For all other text file formats, the trade data should be compiled into a spreadsheet or text file
in column format with one trade per line. At a minimum, MSA requires the profit or loss
amount in dollars for each trade or, alternatively, the entry and exit prices. The order of the
columns does not matter. The formatting details are specified at the time the data are first
read in via the Trades File Format window (see Step 2). A typical spreadsheet of trade data is
shown below.
2
If all trades are the same size, the number of shares or contracts can be entered once on the
Analysis Setup window. Stock traders will want to include columns for the entry and exit
prices; entry prices are used to calculate margin requirements for stock trading. If the data are
entered into a spreadsheet, the spreadsheet file should be saved as a .txt or .csv file. See
Chapter 3, Input Data, Getting Data into the Program, for more information on compiling
data for use in MSA.
If all trades have the same trade risk, defined as the amount you'd lose per share/contract if
the trade were a loss, you can specify the risk after importing the trade data by using the
Specify Trades Risk command of the Trades menu. Trades risks are only necessary when
using one of the position sizing methods that requires them, such as fixed fractional.
Step 2
The simplest way to get the trade data into MSA is to use the Open command of the File
menu to select the file(s) of trade data. This will open and read each file of trade data and
create one or more market-system (.msa) files, depending on whether you choose to combine
the different files of trade data into one .msa file or create a new .msa file for each file of
trade data. If you select multiple files of trade data, you can also have MSA automatically
create a portfolio file consisting of the separate .msa files associated with each file of trade
data.
Alternatively, you can select the New command from the File menu, followed by either the
Import command or the Data Source command of the Trades menu. Either command
allows you to select a file of trade data to read in. The Import command reads in the trade
data but stores it in a separate "trades file". In this case, you're prompted to enter the name of
the trades file later when first saving the .msa file. The name of the trades file is shown under
Data Source.
Note: Using the Open command to read in trade data and create a new .msa file also
automatically creates a new trades file with a default name derived from the name of the file
of trade data.
If you select the file of trade data using the Data Source command directly, the selected file
becomes the trades file, and the trades will be stored and read from this file whenever the
.msa file is in use. The advantage of using the Data Source command over importing is that
if you update the data file with new trades, the market-system (.msa) file will be
automatically updated as well. If you have multiple market-system files using the same data
source (trades file), they will all be updated automatically if you change the trades file. Trade
data are not stored in the .msa file; they are stored in the trades file. The downside of
selecting the file of trade data via Data Source is that the file will be changed by MSA if you
edit the trade data within MSA. Using Import or the File Open command creates a new
trades file, which leaves the original file of trade data unaffected by any changes made in
MSA.
RINA xml files contain the formatting information that tells MSA which data item is which
part of the trade; for example, which item is the entry price, and which item is the trade
profit/loss. For all other text file formats, it's necessary to tell MSA what each column in the
file represents. This is done through the Trades File Format window, as shown below, which
is displayed after the file of trade data is selected. By clicking on each column heading, you
can identify the contents of each column.
3
Trades can also be entered manually using the Edit/Add command of the Trades menu.
This brings up the Edit/Add Trades window. Enter the data for each trade in the fields
provided under "Add Trade..." If entry and exit prices are entered, it is not necessary to also
enter the Profit/loss amount. Similarly, if the stop price is entered, it is not necessary to also
enter the Risk amount. If a stop was not used with the trade, leave the risk and stop price
fields blank. See Chapter 3, Input Data, Editing Input Data, for more information.
After the trade data have been entered into MSA, save the market-system (.msa) file using
the Save command of the File menu. Saving the market-system file will save the trade data
to the text file specified under Data Source (Trades menu) and save all program settings in
the .msa file. Double-clicking on an .msa file will start MSA and open the selected file.
Step 3
Select the Setup command from the Analysis menu. On the Input Data tab, use the drop-
down list next to “Trading Vehicle” to select either Stocks or Futures.
4
If selecting Futures, also enter the Point Value. The point value is used to calculate the
profit/loss amount from entry and exit prices. For example, if an entry price for the E-mini
S&P is given as 1204.75, the point value would be $50. If the same price were entered as
120475, the point value would be $0.50.
5
If all trades entered in step 2 were the same size and the size was not specified in the input
data, the trade size can be entered in the field “Default Trade Size.”
On the Account Settings tab, enter the starting account equity and margin amount (if futures)
or margin percentage (if stocks). If the trade data do not include commission and slippage
costs, enter those costs here. Click Ok to save the settings and exit.
See Chapter 4, Basic Settings, for more information on the Analysis Setup window.
Step 4
Bring up the Position Sizing window by selecting “Position Sizing…” from the Analysis
menu. Select one of the methods listed in the box on the left side of the window.
Most methods have either one or two adjustable parameters. Enter each parameter value in
the corresponding box. The Parameter Studies feature (see Chapter 7) is helpful in choosing
values for the position sizing parameters. See Chapter 5, Position Sizing, for more detailed
information.
Step 5
Explore other analysis features and options of MSA listed in the Analysis menu. For
example, selecting the Monte Carlo Analysis command performs a Monte Carlo analysis by
randomly sampling from the distribution of trades. Try one of the trading rules under
“Dependency Rules…” Equity curve crossover rules can be applied using the Equity Curve
Crossovers tab of the Position Sizing window.
Step 6
Finding the best combination of settings for any given set of trades is largely a matter of trial
and error. Each setting is immediately reflected in the equity curve of the main chart and in
the right-hand pane, which displays summary statistics that correspond to the displayed
equity curve. For more detailed performance results, select Performance Statistics from the
View menu (also see Chapter 12, Viewing the Results). The performance statistics combined
with the shape of the equity curve can be used to determine if the chosen settings are
acceptable. One possible scenario is to use MSA to optimize the position sizing method
while limiting the analysis to a range of trades and saving the rest for out-of-sample testing.
6
You could then select other rules, such as dependency rules or equity crossover rules, and
verify the analysis with out-of-sample testing and Monte Carlo analysis.
Step 7
Once a good combination of settings has been found, use the Trade Size command of the
Analysis menu to get the position size for any upcoming trades.
Enter the current value of your account equity (and optionally the trade risk and market
price) then press the "Calculate" button. The number of shares or contracts plus the required
margin will be displayed for the next trade based on all current settings in the software. For
stocks the required margin is the cost of the trade. For example, with no leverage (100%
margin) and an entry price of $25, 200 shares of stock will cost $5000, which is the required
margin for the trade.
To keep the calculations up-to-date, make sure the trades file, as listed under Data Source, is
up-to-date. For example, you could enter each new trade into the program using the
Edit/Add command (Trades menu) or use the included WriteTrades function for
TradeStation. The Trade Size command is described in more detail in Chapter 5, Position
Sizing, Real Time Position Sizing.
Step 8
Once you've created more than one market-system (.msa) file, you can create a portfolio by
opening a new portfolio (.msaport) file and selecting any number of market-system files.
Create a new portfolio document by selecting New from the File menu and selecting New
Portfolio from the submenu. The available menus should change to include a Portfolio
menu. Select Setup from the Portfolio menu or from the right-click menu and click the
Market Systems tab. Use the Add Market System(s)... button to select any number of existing
market-system (.msa) files that you've already created. On the Settings tab, enter your
starting account equity. Click Ok to save your changes and exit. The resulting equity curve
will display the combined result of all selected market systems, with the trades in order of
exit date and including any rules and settings from the individual market-system files.
7
A short-cut is available for creating a portfolio file from a set of files of trade data. Select the
Open command of the File menu and select multiple files of trade data together by holding
down the shift key or control key while selecting the files. A dialog box will give you the
option of combining the trades from all files into one .msa file or creating multiple .msa files
with an optional portfolio file comprising all the market-system files. The market-system file
or files and, optionally, the portfolio file will be created automatically.
8
Select Position Sizing from the Portfolio menu or from the right-click menu to bring up a list
of each market system with its default position sizing settings. Double-click on any market
system to change the position sizing method and/or parameters. By default, the settings are
retrieved from the market-system file. To change a parameter value, change the Parameter
Source to User Selected on the Position Sizing window then enter the new value in the space
provided.
Equity curve crossover rules can be added to the portfolio from the Equity Curve Crossovers
tab of the Position Sizing window. These rules are in addition to any equity curve crossover
rules defined in the market-system file, which will still apply to the market system after it's
added to a portfolio unless specifically turned off. You can turn off the equity curve
crossover rules in the market-system files by checking the box labeled "Deactivate all
crossover rules ..." on the Equity Curve Crossovers tab of the Position Sizing window.
To add a dependency rule to the portfolio, select Dependency Rules from the Portfolio menu
or from the right-click menu. These rules are in addition to any dependency rules defined in
the market- system file, which will still apply to the market system after it's added to a
portfolio unless specifically turned off. The dependency rules for the market system can be
turned off by checking the box labeled "Deactivate all dependency rules ..." on the Portfolio
Dependency Rules window.
If you change any settings in an individual market-system file, save the .msa file, then select
Reload from the portfolio menu to update the portfolio file.
To get help on any feature or command while using MSA, press F1 at any time. The Getting
Started help screen can be displayed at any time by selecting the Getting Started Screen
command from the View menu.
Chapter 2
Introduction
Overview
Market System Analyzer (MSA) will help you get the most out of your current approach to
trading the markets. MSA is designed to uncover profitable patterns, optimize trade
allocations, and avoid trades that have a low likelihood of success.
Format the chart: change fonts, line and bar colors, grid, title, etc.
The software is designed for both individual and professional traders. The familiar Windows
interface makes the program easy to use, and detailed help files are available if needed to
explain how to use each analysis feature. To get started, all you need is a list of profit/losses
for the trading system or method you want to analyze.
Installation
Minimum System Requirements:
333 MHz processor
64 MB RAM
50 MB hard disk space
Windows XP operating system
If you obtained Market System Analyzer (MSA) by downloading it from the web site, the
downloaded file should be named MSASetup-vxxx-32bit.exe or MSASetup-vxxx-64bit.exe,
where xxx represents the version number of the release and the last part indicates whether it's
intended to run under 32-bit or 64-bit versions of Windows; e.g., MSASetup-v350-64bit.exe
for MSA version 3.5.0 for 64-bit Windows.
Note: Recent versions of Windows are almost all 64-bit, so, in most cases, the 64-bit version
of MSA should be installed. While the 32-bit version of MSA will run on both 32 and 64-bit
versions of Windows, the 64-bit version will be able to take advantage of all available
installed memory to process larger data files. If you're not sure which version of Windows you
have, you can check the System settings under the Control Panel. Both the 32 and 64-bit
versions are compiled from the same code and are functionally identical, including the files
they generate. Because they're the same program, only one may be installed on the same
computer. If your computer runs 64-bit Windows, it's strongly recommended that you install
the 64-bit version. For older computers running 32-bit Windows, install the 32-bit version of
MSA.
To install MSA, go to the Start menu in the Windows task bar and select Run... Browse to the
location of the MSA3 file, click Open, then click OK in the Run window. The installation
should begin.
The installation program will prompt you for the location to install the program files. The
default location is the folder Program Files\Adaptrade Software\Market System Analyzer 3.x\.
You can install the program in another location if you wish. If you're installing in the same
11
folder, it’s recommended that you uninstall the previous version of MSA 3 before installing
the new one.
Once the installation is complete, you should find the MSA icon on your desktop and the
MSA program in the programs menu. You should also find a folder called MSA Examples in
the Market System Analyzer 3 folder. The Examples folder contains sample files of type .msa
and .msaport and sample text files containing trade data. The Market System Analyzer 3
folder also contains a web link to the user's guide in PDF format and the TradeStation
EasyLanguage file WriteTrades32.eld, along with its text file equivalent, WriteTrades32.txt.
The WriteTrades function (see Chapter 3) allows you to generate a text file of trade data from
a TradeStation system for use in MSA.
The licensed (paid) version of MSA also includes the TradeStation file PSCalc32.eld, which
includes the PSCalc TradeStation function (see Appendix). PSCalc implements the position
sizing methods used in MSA. A sample trading system to illustrate the use of the function is
also included.
To uninstall MSA, open " Programs and Features" from the Windows Control Panel, select
the entry for Market System Analyzer, and click the Uninstall button.
A market system is fully represented by the series of trades that results from trading the
system or method on the market. As long as the list of trades is available, the details of the
trading system logic and of the underlying market are unnecessary. This is the approach
adopted by MSA. The list of trades is the fundamental input data required by MSA to define a
market system.
In addition, market systems can be combined into portfolios. Provided two or more market
systems have been established in MSA, a portfolio can be defined as a combination of market
systems. The files for the market systems (.msa files) must be saved in order to create a
portfolio. Once the market-system files are available, a portfolio is created by selecting the
existing .msa files.
In a portfolio, MSA automatically combines the trades from the separate market systems as if
all selected market systems were being traded together in the same account. The program
accounts for overlapping trades in terms of costs and margin requirements and calculates the
performance of the overall portfolio. The settings made in the individual market-system files
are applied to the portfolio. Additional settings can be made for the portfolio overall, and the
position sizing for each market system in a portfolio can be set within the portfolio file.
Each market system and each portfolio is represented by a separate window in MSA. Both
types of windows can be open in MSA at the same time, where each window is identified by a
tab containing the name of the file.
systems and portfolios. In either case, a document window is displayed within a tab. Each
document window contains the main chart, which displays the equity curve and the number
of shares/contracts for the current sequence of trades using the analysis settings and options
currently in effect. In addition to the equity curve, the main chart optionally displays a
moving average of the equity curve and an “ideal equity curve.” The moving average can be
used to modify position sizing (see Chapter 5, Position Sizing, Equity Curve Crossovers).
Below the equity curve is a bar chart for the number of shares/contracts for each trade. The
number of shares/contracts is determined by the position sizing method selected by the user.
To the right of the document windows is a summary pane, which contains a list of
performance statistics for the document currently selected. The performance statistics in the
summary pane correspond to the equity curve and are updated whenever the equity curve
changes based on the user’s selections. The performance results in the summary pane are an
abbreviated version of the full performance report, which can be opened by right-clicking in
the summary pane.
Almost everything that happens in MSA is reflected in the document windows. All changes
and settings made in the program are reflected in the equity curve, in the bar chart for the
number of shares/contracts, and in the corresponding performance statistics in the summary
pane. The equity curve and the bar chart are a visual representation of the program’s data
(the profit/loss sequence) and the analysis options and settings. These settings include the
position sizing method, which adjusts the number of shares/contracts for each trade, the
range of trades to analyze, the order of the trades, trade dependency rules, and other analysis
options. The initial account equity and the slippage and commission costs are also reflected
in the charts.
A commonly used term in MSA is the "current sequence of trades." The current sequence of
trades is the set of trades currently under analysis and in the order displayed in the main
chart. The current sequence of trades may be a subset of the trades originally entered or
13
imported via the Trades menu and may be in a different order than the original trades. The
document window always displays the current sequence of trades. You can change the order
of the trades in the current sequence using the randomize button on the toolbar or choose to
restrict the analysis to a range of the original sequence of trades. In either case, this will
change the "current sequence," although the original sequence, as initially entered or
imported via the Trades menu, remains unchanged. To see the original sequence at any time,
use the Edit/Add command (Trades menu). The current sequence can be restored to the
original sequence at any time by restoring the original trade order and trade range via the
toolbar.
The document windows in MSA can be modified in a number of ways. The summary pane
can be resized by clicking and dragging its left border. The two graphs (equity and trade size)
can be resized in the same manner by clicking and dragging in the horizontal area separating
the two graphs.
Above the main chart, a drop-down menu in the menu bar allows the plotting of the equity
curve to be switched between “Linear” and “Logarithmic.” Logarithmic plotting is useful
when position sizing is applied. An equity curve with equal rates of return from period to
period will plot as a straight line on a logarithmic chart.
Another drop-down menu in the menu bar can be used to change the plotting from "Plot by
Trade" (the default),which plots equity versus trade number, to plotting versus date ("Plot by
Day", "Plot by Week", "Plot by Month" or "Plot by Year"). Plotting by date plots the equity
at the end of the selected period (day, week, month, or year) by the period ending date.
Plotting by date is only available if dates are available for every trade in the trades file.
If a Monte Carlo analysis has been performed, the "Current Sequence" drop down menu can
be changed to "Monte Carlo", which plots four equity curves together: the equity curve for
the current sequence of trades, the equity curve representing the chosen confidence level for
Monte Carlo analysis (e.g., 95%), the equity curve at the corresponding lower confidence
band (i.e., 100 - confidence level, such as 5% for a confidence level of 95%), and the equity
curve at 50% confidence. See the chapter Monte Carlo Analysis for more information.
The trade range option in the menu bar allows the analysis to be restricted to a range of
trades. After entering the first and last trades to include in the analysis, click the
“Recalculate” button in the menu bar to update the analysis. The trade range can also be
changed using the calendar controls adjacent to the trade number edit boxes.
Lastly, clicking on the equity curve will display data for the selected trade in a box that
tracks the cursor, as well as in the status bar at the bottom of the chart. Using the zoom
feature, any part of the chart can be magnified and later restored to normal magnification.
Program Conventions
MSA contains a number of features that are common throughout the program. Many of these
conventions may be familiar from other Windows programs you already use. Learning these
program conventions will make using MSA more convenient and efficient.
One such convention is context menus. In most windows in MSA, including document
windows and the performance reports, you can right-click anywhere in the window to bring
up a context menu with common program commands. Right-clicking in the document
window over the charts brings up the largest context menu, which contains commands for
setup, position sizing, dependency rules, chart formatting, and other common commands. It’s
14
often more convenient to right-click than navigate to the menus in the menu bar. This right-
click menu can be customized using the Customize command (View menu), Menu tab.
MSA 3also includes the common convention of copying to the clipboard. Any window that
contains a context menu can be copied to the clipboard. For example, the main chart can be
copied using the copy button in the toolbar, by right-clicking and selecting Copy, or by using
the Ctrl-C keyboard shortcut. This copies the entire chart image to the clipboard as a bitmap.
The right-hand performance summary pane can be copied by right-clicking in the pane or by
clicking in the pane to set the focus then using the Ctrl-C shortcut. In this case, the copy
command copies the text from the pane to the clipboard. The text is copied in tab-delimited
format so that it can be pasted into a spreadsheet correctly. Similarly, the different
performance reports can be copied to the clipboard as tab-delimited text.
Another convention in MSA is that the different performance reports in MSA all contain the
same menus, which include commands for copying, as described above, printing, and saving
(exporting) to a text file. For exporting, the available formats are tab-delimited text (.txt
files), comma-delimited text (.csv), unformatted Word documents (.doc), and web files
(.htm).
Similar to other Windows programs, the menus available in the menu bar of the main
window of MSA change depending on the type of document currently open and selected. In
particular, you’ll notice that when a market-system (.msa) document is open and active, an
Analysis menu is present. If you then open a portfolio (.msaport, or .msp) document, the
Analysis menu will no longer be accessible, but a Portfolio menu will be present. The
available menus and associated commands are appropriate to the type of document that’s
currently active. To see the Analysis menu again, you would simply have to click on the tab
for a market-system document to make it the active window.
Lastly, MSA uses the Windows help system convention. This means that you can bring up a
help topic for a command or open window by pressing the F1 key. If a help topic is available
for that command or window, the help system will be opened with the corresponding topic
displayed.
Data Requirements
MSA is designed to extract the maximum amount of information from the minimum amount
of data. Because a market system can be defined by its trades, the only data required by the
program is a list of profit/losses for the trading system or method you want to analyze.
Optionally, to apply fixed fractional position sizing, or a variant of fixed fractional called the
profit risk method, you will also need the risk of each trade. The risk is defined as the dollar
amount that the trade would lose per contract (share) if it were a loss. Commonly, the trade
risk is taken as the size of the money management stop applied, if any, to each trade. If your
trading doesn’t use protective (money management) stops, the risk can be taken as the largest
historical loss. Trade risks are only used with these two position sizing methods and in the
calculation of R-multiples.
You may also specify trades in terms of the entry and exit prices, along with the trade
direction – long or short, instead of the profit/loss itself. For example, if a stock was bought
at a price of 52 and sold at a price of 54, the profit/loss would be $2 per share. If you traded
100 shares, the total profit/loss would be $200. You can either enter $200 as the profit/loss,
15
with a trade size of 100 shares, or enter the entry and exit prices of 52 and 54. Optionally, the
stop price can be entered in place of the risk. If, for example, a sell stop was placed at a price
of 49, the trade risk would be 52 - 49 or $3 per share. Alternatively, the stop price of 49
could be entered.
Each trade can optionally include the date and time for the entry and exit. For the purpose of
constructing the equity curve, the exit date/time is used; i.e., the equity is accumulated when
the trade is closed out. Entry dates/times are used primarily to determine the cost and margin
requirements of open positions.
The Trade menu provides the commands needed to work with trade data in MSA. There are
several methods of entering the trade data into the program. Trade data can be read from an
existing text file specified via the Data Source command, imported through the Import
command, or selected via the File Open command. Data can be entered manually through
the Edit/Add command, or a synthetic series of trades can be created based on specified
statistical properties of the trades (see Chapter 3, Input Data, Creating Trades from
Statistics). This method randomly generates a series of trades based on the average profit,
average loss, maximum profit, maximum loss, and percentage of winners. See Chapter 3,
Input Data, Getting Data into the Program.
If the trade risk value is the same for all trades, the Specify Trade Risks command of the
Trades menu can be used to set the trade risk for all trades to one of the following values: the
largest loss, maximum loss, average loss plus N standard deviations, or a user entered value.
Trade data are only entered for market-system documents, not portfolio documents. If a
portfolio document is active, the Trades menu will not be available. To work with the trade
data in a portfolio, open the market system containing the data and work with the data in the
market-system document.
When a market-system document is saved as a .msa file, the trade data are saved in a
separate trades file, which is listed under the Data Source command. With regards to trade
data, the .msa file only saves the name of the trades file. Using the Save command saves both
the .msa file and the trades file.
Examples
To demonstrate how to get started with Market System Analyzer (MSA), there are several
sample data files provided with the installation. These files can be found in the MSA
Examples folder of the installation folder, which is typically Program Files\Adaptrade
Software\Market System Analyze 3\. The files include market-system files (extension .msa),
a portfolio file (.msaport), and the trades files (.csv) read by the market-system files.
To open the samples, use the Open command of the File menu, navigate to the Examples
folder, select all available .msa files, and click the Open button. Open the portfolio file using
the same command by selecting the .msaport file.
The file Example1.msa is a stock trading example. Click the document’s tab to make it the
active document, as shown below.
16
Go to the View menu and select Equity Table. With the Equity Table still open, try clicking
the Randomize button in the toolbar. Randomizing a sequence of trades can be an effective
way to learn how the order of the trades affects trading performance. Also, by randomizing
the sequence, we can determine if our performance expectations depend on a particular
ordering of the trades that may never reoccur. When you randomize the trade order, the chart
should redraw with the trades in a different order, and the results to the right of the chart
should show the corresponding performance for the new sequence of trades. Also, you
should see the order of the trades in the Equity Table change to match the order in the chart.
Now restore the trades to the original order by clicking the Restore button in the toolbar.
Now go to the Analysis menu and select the Setup command. On the Account Settings tab,
enter a value of $5,000 for the starting account size and click OK. The chart will update to
reflect the new account size. Now choose Position Sizing from the Analysis menu and select
"Fixed Amount of Equity" from the Position Sizing Method tab. Enter an equity amount of
$20,000 per unit. Where it says “When plotting, use parameter values from…”, make sure
the first option in the drop-down list (“User entries”) is selected. Click OK. The chart should
redraw with the new position sizing method, which should be indicated in the summary pane
to the right of the chart. Now go back to the Position Sizing window and return the position
sizing to “Fixed risk (aka fixed fractional).”
Try running a Monte Carlo analysis by pressing F4 (function key) or selecting the Monte
Carlo Analysis command from the Analysis menu. This will bring up a window displaying
the Monte Carlo analysis results. Now press F1 or click on the Help command on the results
window. This should bring up a help window with information on the results window. In
general, pressing F1 brings up a help topic for the command currently selected or the window
currently displayed.
17
To see how the Parameter Studies command works, press F5 or select the Parameter
Studies command from the Analysis menu. On the y axis pull-down menu, select “Max %
DD.” On the x axis, select Fixed Fraction. Enter 10 in the box labeled "Max X Value" and
click on the PLOT CURVE button. The plot should appear as shown above, where the
drawdown increases with increasing values of the fixed fraction. Try changing the y axis
parameter and plotting the curve again. Now try selecting "Monte Carlo Analysis" in the box
below the chart labeled "Calculate Y values using." The plot should take much longer to plot
because each point requires a Monte Carlo analysis.
18
Close the Parameter Studies window and select the Optimize Position Sizing command
from the Analysis menu (F7). The Optimize Position Sizing window will appear, as shown
above. Select Net Profit as the performance measure to maximize, check the "Limit max
percent drawdown..." box, and enter a maximum drawdown value of 20%. Optimize over all
trades in the current sequence and optimize using the current sequence of trades (as opposed
to Monte Carlo analysis). Now click the calculate button. The optimal results will appear in
the bottom part of the window. You should find that the optimal value of the fixed fraction is
3.12%. The worst-case drawdown at this value is 19.8%, matching our drawdown limit of
20%.
Close the Optimization Results window and right-click in the summary pane or select
Performance Results from the View menu. This will open the performance results window.
Try the different tabs. The Settings tab displays the program settings under which the results
were calculated. The Summary tab displays the results in summary form, including separate
columns for long and short trades, if applicable. The Return Tables tab presents the results
for annual, monthly, weekly, and daily periods. There are also tabs for the dependency and
significance test results. The settings for the significance test are made on the Options tab of
the Analysis Setup window (Analysis menu). Lastly, try different dependency rules using the
Dependency Rules command and see how they affect the performance results.
Let’s move to the portfolio example. Click on the tab for the document
PorfolioExample.msaport. Now right-click on the chart and select Setup from the context
menu. The Market Systems tab displays the market-system files that compose the portfolio.
You should see three market-system files. If you double-click on a file in this list, the
market-system file will open in its own window. You can also use this window to add
additional market systems or remove existing market systems from the list.
Now select the Settings tab of the Portfolio Setup window. This is where you enter the
starting account size for the portfolio, as well as basic settings for the portfolio Monte Carlo
analysis, dependency analysis, and significance test.
The position sizing for the portfolio is set for each market system individually. When a
portfolio is initially constructed, the position sizing method and parameter values for each
market system are retrieved from the market-system file. To set the position sizing to
different values, select the Position Sizing command of the Portfolio menu. This opens the
Portfolio Position Sizing window, as shown below.
To change the position sizing settings for any market system, either double-click on the
market system in the list or select from the list and click the Edit Selection button. To set the
position sizing for all market systems to the same method and/or parameter values, click the
Set All button.
The Portfolio menu is similar to the Analysis menu for market-system documents. Most of
the analysis functions available for portfolios are listed in the Portfolio menu, including
dependency rules, Monte Carlo analysis, and optimizing position sizing. These commands
are also available in the context menu by right-clicking in the chart area.
19
The best way to learn MSA is to try things. Select a list of trades from your favorite system
or trading method using Data Source, and try the various analyses. If you have questions
along the way, try pressing F1 to bring up the associated help topic at any time. Also try the
FAQ (Frequently Asked Questions) list of the help system or search for a help subject
using the help index.
Chapter 3
Input Data
To save time when a creating a new market-system (.msa) file, the file can be created at the
same time the data are specified by using the Open command of the File menu. In this case,
just use the Open command to select the file of trade data. The new .msa file will be created
automatically after the data are read in, and a new trades file will be created with a default
name derived from the name of the selected file of trade data.
Note: MSA stores all trade data in the trades file, rather than in the market-system (.msa)
file. This makes it possible to update or alter the trade data outside of MSA. Also, only when
the file of trade data is selected using the Data Source command is the trades file the same
as the original source of trade data. In all other cases, the trades file is a separate file. The
advantage of using Data Source to select the original file of trade data to be the trades file is
that if you update the original data file with new trades, the market-system (.msa) file will be
automatically updated as well. If you have multiple market-system files using the same data
source (trades file), they will all be updated automatically if you change the trades file. The
drawback of selecting the original file of trade data to be the trades file is that the original file
will be changed by MSA if you edit the trade data within MSA. Using Import or the File
Open command creates a separate trades file, which leaves the original file of trade data
unaffected by any changes made in MSA.
MSA can read trade data presented in two different file formats. The first one is RINA xml
format. This type of file is used by several trading platforms, including TradeStation and
MultiCharts, to save strategy details, price data, and trading results. Among other data, this
format specifies the trade entry and exit dates/times and prices, as well as the profit/loss
amount, trade size, and trade direction (long or short). If a RINA xml file is supplied, no
further formatting or specification is required (i.e., the Trades File Format window, as
described below, is not used).
The other formatting option is a text file with one trade per line or one trade every other line.
Each column in the file will contain a different data field, such as the profit/loss, entry price,
exit price, trade size, etc. The simplest such file would contain a single column of the profit
or loss for each trade. A typical text file of profit/loss data for MSA is shown below.
21
300.00
-250.00
500.00
175.00
-425.00
-300.00
350.00
...
...
For example, the first trade was a profit of $300.00, and the second trade was a loss of -
$250.00. The third trade was a profit of $500.00, and so on. A more complete file might look
like the spreadsheet shown below. Each line contains the data for one trade: entry date/time,
entry price, exit date/time, exit price, stop price, trade direction, profit/loss, trade risk, and
position size.
MSA can read the data fields listed in the table below.
It’s not necessary to enter data for all fields. For example, if the entry price, exit price, and
trade direction (long or short) are entered, MSA will calculate the profit/loss amount, so it’s
not necessary to enter the profit/loss amount as a separate item in this case.
Trade Risk
Trade risks work the same way. The risk is defined as the dollar amount the trade would lose
if it were a loss. Commonly, the trade risk is taken as the size of the money management stop
applied, if any, to each trade. For example, a stop size of 10 points in the E-mini S&P would
be a risk of $500 per contract. If the entry price, stop price, and trade direction are entered,
23
it’s not necessary to enter the risk amount in dollars. MSA will calculate the trade risk from
the entry and stop prices in this case. If a profit/loss or risk value is entered, the amount
should be for the same number of shares or contracts listed in the Trade Size column.
If you don’t use protective (money management) stops, the risk can be taken as the largest
historical loss. Trade risks are only used with two position sizing methods (fixed fractional
and profit risk) and for calculating R-multiples.
Trade Size
The trade size field is also not required in every case. If all the trades are for the same
number of shares or contracts, the size can be entered separately on the Analysis Setup
window on the Input Data tab under Default Trade Size. The trade size field is also not
required if the trade data are entered in terms of prices. However, if you’re entering historical
trade data and you want to be able to plot the trades using the actual, historical position sizes,
it will be necessary to include a column for the trade size.
ATR
The average true range field is provided for use with the percent volatility position sizing
method. If you don’t plan to use this method, it’s not necessary to provide ATR values. If
you do provide values for this field, the ATR value should be calculated on the bar prior to
trade entry to avoid the benefit of hindsight. The ATR values should be provided in price
units; i.e., the same units as the entry and exit price. The point value provided on the Setup
screen will be used to convert price units to currency amounts (e.g., dollars).
Currency Conversion
This field is used to convert the price data to a different currency. The field value is
multiplied by the entry price, exit price, stop price, and ATR values. It defaults to a value of
1.0 if not provided. It is not multiplied by the P/L and risk amounts, which are assumed to be
provided in the same currency units as the account.
The currency conversion field can be used to provide a pip value for forex trades. Depending
on the currency, the pip value may change from trade to trade. If currency prices are used as
input data, the currency conversion field will act as the pip value when the trading vehicle is
set to “Stocks”.
Trade Type
The trade type field will normally be set to “regular” (or a value of 0) to indicate a trade. If
this field is not provided, trades are assumed be “regular” trades. If this field is set to “Cost”
or “Fee” (“C” or “F”) or to a value of 1, the profit/loss amount will be assumed to represent a
cost or fee amount. Costs and fees include such items as commissions, trading fees, and
miscellaneous adjustments to account equity. A cost or fee amount is deducted from the
account equity at the date/time specified by the trade exit date/time. Costs/fees are not
subject to position sizing.
If this field is set to “Addition” or “A” or the value 2, the profit/loss amount will be
interpreted as an addition to or withdrawal from equity. Additions are positive P/L values;
withdrawals are negative P/L values. An addition/withdrawal amount is treated differently
than a cost/fee amount. The returns and drawdowns are adjusted so that an
24
addition/withdrawal does not directly alter the performance. For example, if you have a 50%
return at the end of the year, and withdraw half of your profits for the year on December 31 st,
the rate of return should still show a 50% return, despite the lower equity after the
withdrawal. If the withdrawal were entered as a cost/fee, the return would be displayed as
25%, rather than 50% in this example.
A schedule of account withdrawals can be entered on the Setup window, Account Settings
tab, to withdraw a set amount or percentage of equity at regular intervals (every week,
month, quarter, or year). Withdrawals are discussed in more detail in the next chapter.
If your trading software supports the RINA xml format for trade results, you can save or
export your results in that format. MSA directly reads RINA xml files without the need for
additional formatting specifications.
To create a new MSA file based on the file of trade data, the easiest method is to select Open
from the File menu. If you select multiple files of trade data at the same time, this will bring
up the File Creation Options dialog, as shown below.
25
This dialog gives you the option to create one market-system (.msa) file for each file of trade
data or to combine the files into a single .msa file. If you select the option to create multiple
.msa files, you can optionally choose to also combine the separate .msa files into a portfolio.
For each newly created .msa file, a trades file will be created based on the name of the file of
trade data. As with all trades files, you can view the name of the file and/or select a new one
using the Data Source command.
If you choose to select the file of trade data using Data Source directly, the Data Source
window is opened, as shown below.
After selecting the text file of trades, click the Save button to read the data. If the selected file
is not a RINA xml file, MSA will open the Trades File Format window, shown below, to
allow you to specify the format of the selected file. The Trades File Format window is also
displayed when importing a text file of trades. There are several options available in check
boxes below the data display that control how the data are interpreted. In the section labeled
“Delimiters,” check the box or boxes that describe how the columns of data in the text file
are separated. Columns can be separated by commas, spaces, tabs, and/or semi-colons.
Note: If a RINA xml file is selected as the trades file (i.e., selected via Data Source), MSA
will prompt you for a different trades file when saving the .msa file if the trades have been
modified or edited. This is because MSA does not write to RINA xml files; it only reads
from them.
26
To skip over one or more lines at the top of the text file, such as a line of column headings,
check the box labeled “Skip first [ ] lines.” Click the arrows to select the number of lines to
skip. If the data for each trade occupy two lines, check the next box, “Merge lines two at a
time.” This will combine each pair of lines into one long line. For example, the trades list
from a TradeStation performance report uses two lines per trade, so this option is required to
properly interpret files of that format. The final option, “Profit/loss and risk data are
expressed as percent of equity,” accommodates the case where instead of dollar amounts for
the profit/loss and trade risk, percentages are used. If this box is checked, the profit/loss and
risk values are interpreted as percentages of the initial account equity.
The "Preset format" pull-down menu at the top left of the Trades File Format window allows
you to set the column headings to match a TradeStation Trades list, a WriteTrades3 file, or a
general text file. To clear the column headings, select "None/Clear Format." Regardless of
which preset format you select, you can change the heading of each column of data if
necessary by clicking on each column heading, which opens the pop-up window “Select data
label:” shown above.
For example, if the third column is the entry price, you would click on the heading for
column three, and double-click on “Entry Price” from the pop-up window. This identifies the
third column as containing the entry prices. Any column you don’t want to import should be
left blank, which you do by selecting the label "No label/Skip." Once all the pertinent
columns of data have been identified, click the Ok button, then click Ok on the Data Source:
Setup Trades File window. The data will be read in and plotted in the chart window.
Once data have been read in from a text file, select Save from the File menu to save the
current .msa file. The name of the trades file you selected in Data Source will be stored in
the .msa file, but the trades themselves are stored in the trades file. If you have not yet
selected the trades file, you will be prompted to select one or to enter a name for a new one.
If the market-system file has not been previously saved, you will be prompted to enter a
name for the file. The name of the file will be shown in the title bar of the main window.
27
After entering trade data for a new market system, go to the Analysis Setup window
(Analysis Setup command) to enter the corresponding settings, such as whether the data
represent stocks or futures, the starting account size, margin, etc. See Chapter 14, Menu
Commands, Analysis Menu Commands, Setup Command.
The WriteTrades function can be found in the installation directory for MSA, typically
Program Files\Adaptrade Software\Market System Analyzer 3\. The exact name of the
function and file depends on the version of MSA. As of this writing, the most recent version
is WriteTrades32 (for MSA version 3.2.0), and the file name is WriteTrades32.eld. To install
the function, either double-click on the file or open TradeStation and use the Import/Export
EasyLanguage command from the File menu. In MultiCharts, open the PowerLanguage
editor and select the Import command from the File menu.
To use the WriteTrades function, all you need to do is insert the following line at the end of
your system:
where TradeRisk is the risk of the trade in currency units (e.g., dollars), StopL is the stop
price for a long trade, StopS is the stop price for a short trade, NATR is the period (number
of bars) for calculating the average true range (ATR), CurrConv is the currency conversion
factor, and “filename” is the name of the file to write the data to, including the full path
name. For example, suppose you use a 12 point stop in the E-mini S&P, which is equivalent
to a risk of $600 per contract. Let’s also say that the stop is relative to the entry, which is at
the close of the most recent bar. Assuming you want to write the data to the file
c:\tradedata.txt, you would write
Here, a length of 10 bars has been entered for NATR, although the ATR will only be used if
percent volatility position sizing is chosen. Since there is no need for currency conversion, a
value of 1 has been entered for CurrConv.
As explained in the previous section, it’s not necessary to have both the dollar value of risk
and the stop prices, so this could also be written as
If you don't use a stop or don't want to use fixed fractional or profit risk position sizing,
which are the only position sizing methods in MSA that requires the trade risk, specify "0"
for the first three inputs:
When selecting a text file created from WriteTrades using the Data Source command, select
the pre-set column format “WriteTrades3 function” on the Trades File Format window. This
will pre-select the column headings correctly to match the data generated by the function.
The return value variable, Value99, can actually be any variable you choose. EasyLanguage
provides pre-declared numeric variables Value1 - Value99. Most EasyLanguage code uses
the lower-numbered variables, if any, so using Value99 should avoid conflicts in most cases.
To make sure the function works properly, please note the following:
1. The WriteTrades function should be called as the last line of your trading system,
outside of all loops and other program statements.
2. If entering a value for the trade risk (first function parameter), the risk value should be
for the same number of shares or contracts as the corresponding trade profit/loss. For
example, if the 20th trade was for 300 shares, then when WriteTrades is called for the
20th trade, the first input to the function should be the dollar value of the risk for 300
shares. In many cases, it will be easier to enter the stop price (2 nd and 3rd parameters)
than the stop amount.
The EasyLanguage code for the WriteTrades function contains a comment block at the top of
the code with further details about the function inputs and usage. The code can be viewed in
the EasyLanguage editor in either TradeStation or MultiCharts.
The Create Trades from Statistics command brings up the Create Trades from Statistics
window, as shown below. Fill in all the fields and indicate using the drop-down list whether
the created trades should replace the existing trades or add to the existing list of trades. If you
decide to replace the existing trades and you don’t want to lose them, make sure to save the
open file before clicking the Create Trades button.
You can create as many trades as you want, up to available memory limits. For the largest
losing and average losing trade statistics, you can use either a positive or negative number
with the same result. The program uses a proprietary algorithm to randomly generate the
series of trades so that it approximates the specified statistical properties. The more trades
that are generated, the closer the statistics of the generated series will match the input
statistics. A sample size of at least 100 trades is recommended to generate a representative
series.
For the trade statistics (largest winning, average winning, largest losing, and average losing
trade), enter the dollar amounts corresponding to the trade size entered in the box next to
“Trade amounts are for.” For example, if you entered 100 shares in the “Trade amounts …”
box, the trade amounts should be for 100 shares.
29
After using this feature to generate a series of trades, you can check how closely the
statistical properties of the generated series match the input statistics by selecting the
Performance Results command from the View menu. If the statistics are not sufficiently
close to the statistics you entered, try repeating the process. Because of the random nature of
the process, a second series of trades based on the same inputs will often have slightly
different results, which may match the inputs more closely.
After generating the trades, dates can be attached to the trades using the trade editor
(Edit/Add, Trades menu) via the Set Date Range button.
The Specify Trade Risks command brings up the Trade Risks window, as shown above.
This window offers several options for specifying a risk value to be assigned to existing
trades. The options are as follows:
30
1. The largest historical loss. This is the largest loss among the trades currently loaded into
MSA. This option is often used with fixed fractional trading.
2. The average loss. This is the simple numerical average of all losing trades.
3. The average loss minus X standard deviations. This subtracts a user specified multiple of
the standard deviation of the losing trades from the average losing trade. Enter a value
for X, the number of standard deviations, then click the Calculate button to compute the
risk value.
4. A user-specified risk value. This value can be entered as either a positive or negative
number (it has the same effect either way). A typical value would be the size in dollars
of the money management stop used for trading.
For the Trade Risk window, the loss and risk amounts are always on a per-share or per-
contract basis. For example, if the largest loss in the trade history is -$500, and this trade
took place with 100 shares, then the largest historical loss shown in the Trade Risks window
would be $5.00 (-$500/100 shares is a loss of $5 per share). This also applies to user-
specified risk values (i.e., the option “Use the following value:”). When using this option, the
risk value should be entered on a per-share basis for stocks or a per-contract basis for futures.
After specifying the risk value, choose whether to replace all current risk values or assign the
specified risk value only where risks are currently undefined. The latter option is useful if
you have already manually entered risk values for some trades and want to fill in the
remaining risks with the value specified here.
The fixed fractional (fixed risk) and profit risk position sizing methods are the only position
sizing methods of MSA that requires risk values. The calculation of R-multiples also requires
risk values.
Note that this command directly modifies the input data. The specified risk values are stored
in the trades file.
The top part of the window lists the trades currently in the program. To edit a trade, select it
from the list then click the Edit Trade button or simply double-click on the trade you want to
edit. This will bring up the edit window (Edit/Add Trade), shown below. Make your changes
and optionally use the Next or Previous buttons to navigate to other trades in the list. Click the
"Save and Close" button when done editing. The list of trades in the Edit/Add Trades window
will be updated with the edited trades.
To add a trade, use the Add Trade button beneath the trades list or the Add New button on the
Edit/Add Trade window. As explained in the section “Getting Data into the Program” earlier
in this chapter, not all data fields are required. For example, if the entry price, exit price, stop
price, and trade direction are entered, the profit/loss and risk amounts are not necessary. The
trade will be added above the highlighted trade or above the last trade selected from the list. If
there is no current selection, the trade will be added to the bottom of the list.
31
When entering a new trade, the trade type (“Type of Trade”) defaults to “Regular trade”. As
explained above under the description of the Trade Type input data field, trades can also be
entered to represent cost/fees or additions/withdrawals. To enter either of these trade types,
select the corresponding option under Type of Trade and enter the amount in the Profit/Loss
field.
If you want to add a trade to the bottom of the list, scroll to the bottom and click in the blank
space below the last trade. This will deselect any trade that may be selected. Clicking Add
Trade will then add the new trade to the bottom of the list. The trade being edited or added is
indicated by the Trade Number displayed on the Edit/Add Trade window. The Copy Trade
button initializes the Edit/Add Trade window with the trade data from the selected trade and
adds it to the bottom of the trade list when you click Finish. You can delete one or more trades
by selecting them from the list then clicking the Delete Trade button below the list. Multiple
trades can be selected using the Shift and Control keys.
To export the trade data to a text file, use the Save to File command on the File menu located
on the Edit/Add Trades window (not the File menu on the main frame window of MSA).
Enter or select a file name to export to then click Save. The file can be saved to any of the
following formats: tab-delimited text (.txt), comma-delimited text (.csv), unformatted Word
(.doc), or html (.htm).
Chapter 4
Basic Settings
Overview
Once the trade data are entered into Market System Analyzer (MSA), there are a number of
settings that should be made to properly set up the market-system document. These basic
settings include specifying the trade vehicle (stocks or futures), the starting account equity,
margin, point value (for futures), account locale, and position sizing and withdrawal options.
For market systems, these settings are made via the Setup command of the Analysis menu.
The most important basic settings for portfolios are the list of market systems in the portfolio,
the starting account equity, and the account locale. These settings are made using the Setup
command of the Portfolio menu.
If the trading vehicle is futures, the point value for the futures contract can be entered in the
space following “Point Value (futures only):” The point value is used to determine the value
of a futures position, which is required with several position sizing methods, such as the
leverage target method. The point value is multiplied by the price to determine the value of
the position. For example, if the price of an E-mini S&P futures contract is 1225.00, the point
value would be $50, and value of the position would be 50 x 1225 or $61, 250. For forex
trades, the point value can be set using the “currency conversion” field in the input data (see
Chapter 3).
33
The drop down menu next to “Calculate profit/loss and/or risk using:” is used to specify how
the input data are used to determine the profit/loss and risk values when both profit/loss/risk
and price data are available. If the first option, “Profit/loss/risk data,” is chosen, the profit/loss
and risk data themselves are used. If the second option, “Prices (entry/exit/stop),” is chosen,
the price data are used to calculate the profit/loss and risk values. The default is
Profit/loss/risk data.
The next entry on this tab is the default trade size. This is used to interpret the profit/loss and
risk data if the trade size has not been included with the input data. For example, if the
profit/loss amount is $500, and there is no corresponding trade size in the input data, the
default trade size will be used. If the default trade size is 100 shares, for example, then the
profit/loss value of $500 will be interpreted as $500 per 100 shares or a profit of $5 per share.
This can be used to simplify the data entry when all trades are for the same number of shares
or contracts. In this case, the trade size can be entered here, and the trade size field can be
skipped when importing or entering the data. If the trades are specified in terms of entry, exit
and stop prices rather than profit/loss and risk amounts, the default trade size will only be used
when the position sizing is set to “None.”
The first check box in the bottom part of the window can be used to indicate that the
profit/loss and risk data are percentages of the initial account equity rather than dollar
amounts. For example, if a trade profit/loss is 1.4% of equity, it could be entered as 1.4 rather
than the equivalent dollar amount. Checking the box would instruct MSA to interpret the
value 1.4 as a percentage. If the trade profit/loss data already include an amount for
commissions, slippage and fees, check the middle box. If this is done, the fees will not be
deducted from the profit/loss amount but will be listed in the results. Similarly, if the entry
and exit prices include the slippage, you would check the next box. In this case, MSA will not
deduct the amount entered for slippage from the profit/loss results determined from the price
data (if applicable).
34
The last box is used to automatically reload the chart data at specified intervals. If this box is
checked, the program will reload the trade data from the trades file every specified number of
hours, minutes, and seconds. For example, if you entered zero in the first box, 3 in the second
box, and 15 in the last box, MSA would reload the chart data every three minutes and 15
seconds. This is intended for day traders who have set up their trading software to update the
trades file after each trade. For example, a system written for TradeStation could use the
WriteTrades function included with MSA for this purpose.
The "Trade size limit" puts a limit on the number of shares or contracts generated in
producing the equity curve. The default is 1,000,000 shares or 5000 contracts. One reason to
change this value would be to set it to the exchange's position size limit for the futures
contract being traded. For example, if you're trading a futures contract that has an exchange-
mandated position size limit of 500 contracts, you could change this value to 500.
You can also select the locale for your trading account on this tab. The locale determines the
currency unit used for display purposes (dollar, Yen, Euro, etc.) as well as the number format.
35
The default value is the locale set in Windows in the control panel under Regional and
Language Options.
The next set of entries on this tab is grouped according to whether the trading vehicle is
futures or stocks. If the trading vehicle is futures, the initial margin requirement per contract,
the round turn slippage, and the round turn commissions and fees should be entered. “Round
turn” means that the slippage and commission/fee amounts are deducted once per trade rather
than once at the entry and again at the exit.
If the trading vehicle is stocks, the margin requirement is entered as a percentage of the
purchase price of the trade. For example, if the margin is 50%, the equity in the trading
account would need to be at least 50% of the purchase price of the trade. To purchase 100
shares of a $25 stock would require $1250. A “margin account” in the U.S. generally allows
no less than 50% margin.
Margin is related to leverage. The lower the margin requirement, the higher the leverage. The
relationship is as follows: Leverage = 100/margin. For example, a margin of 50% implies
leverage of two, or 2:1 (“two to one”). Margin of 25% would be leverage of 4:1.
For stock trading, the slippage and commission and fees are entered as the amount per side.
This means that the amount is deducted twice from each trade, once at the entry and again at
the exit. The values can be specified as “per share” or “per trade.”
Periodic Withdrawals. This option allows you to set up a schedule of regular withdrawals
within the simulation that MSA performs. Withdrawals can be specified as a fixed amount
(e.g., $5000) or a percentage of account equity (e.g., 4% of equity). The withdrawals can be
scheduled weekly, monthly, quarterly, or yearly. The actual withdrawal date/time is 1 second
prior to midnight on the last day of the week, month, quarter, or year. Once the settings are
made, withdrawal “trades” are added to the trades file at each withdrawal date. These
withdrawal trades are given the symbol “Period WD” and can be examined using the
Edit/Add command of the Trades menu. The value of the withdrawal (either amount or
percent of equity) will be shown in the Profit/loss field. The trade type will be shown in the
Edit/Add Trades list as either “Amt-Add/With” for a withdrawal amount or “Per-Add/With”
for a percentage withdrawal.
Periodic withdrawal trades cannot be changed via the trade editor. To change or remove the
withdrawals, use this tab of the Setup command. To add one-time additions or withdrawals,
use the trade editor and set the trade type to one of the Addition/Withdrawal options, as
discussed in Chapter 3, Input Data.
Because periodic withdrawals are implemented as a specific type of trade, they can only be
added to market systems, not portfolios. When a market system with periodic withdrawals is
added to a portfolio, the withdrawals will be automatically included in the portfolio. Periodic
withdrawals specified as a percentage of equity will be applied to the portfolio equity.
Options tab
The Options tab, as shown below, contains a number of options for position sizing, Monte
Carlo analysis, dependency analysis and the significance test. The first option, "No skipped
trades. Trade a minimum of [] shares/contracts/units per trade", if checked, means that even if
the account size is too small to support one shares/contract/unit, as determined by the position
sizing method, the specified minimum number of shares/contracts/units will be traded
nonetheless. This option can be useful for smaller accounts, where you might choose to
exceed the risk limits imposed by the position sizing method. It is also a way to force the
simulation to trade through a drawdown that would otherwise result in a position size of zero.
36
The second option in this section, "Trade [] shares/contracts/units per trade until equity
reaches []," means that the program will trade exactly the specified number of
shares/contracts/units, ignoring the position sizing method, until the equity reaches the
specified value. At that time, the chosen position sizing method will take effect. This option
can be useful for small futures trading accounts, where typical position sizing methods often
switch from one contract to two after a win then back down to one contract after a loss. To
avoid this kind of "unstable" position sizing, it's sometimes preferable to simply trade a fixed
number of contracts until the account equity is large enough to take full advantage of a more
formal position sizing method, such as fixed fractional trading.
The next option is to trade in units of a specified number of shares of contracts. This is
particularly useful for stock trading, where you may want to trade in “even lots” of, say, 100
shares. In this case, you would check the option and enter 100 in the box. The number of
shares for each trade will be a multiple of 100. When this option is checked, some parameters
and results will be listed in terms of “units” rather than shares or contracts.
The next section of this tab presents options and settings for Monte Carlo analysis. The
number of samples used in performing the Monte Carlo calculations can be entered here. The
default is 500 samples. Choosing more than this will provide more accurate results but will
slow down the analysis proportionally to the number of samples; twice as many samples will
take twice as long, for example. You can also select the probability at which the Monte Carlo
results are recorded. The default is 95%. Any value from 50% to 100% can be entered. This is
37
the probability that is displayed in the Monte Carlo Results window. Also see Chapter 6,
Monte Carlo Analysis, Overview.
You can choose between two types of Monte Carlo analysis. Selecting "Include all trades in
MC analysis" will perform a standard Monte Carlo analysis based on randomizing the trade
order. Following the analysis, the equity curve plot will display four lines: the current
sequence of trades, the equity curve at the specified confidence level, the equity curve at the
lower confidence level (100 minus the specified confidence), and the equity curve at 50%
confidence.
If you choose "Predict equity curve over last N trades", where N is the number entered in the
edit box, the trades prior to the last N trades will be randomly sampled (with replacement) to
extrapolate the equity curve over the last N trades based on the prior trades. As with the other
option, four equity curves will be displayed, this time over the last N trades: the current
sequence and the curves at high, low, and median confidence. This feature can be used to
detect when the trading strategy is underperforming based on the prior history. In particular, if
the current sequence is below the predicted curve at high confidence (i.e., the lower curve),
the strategy may be out of sync with the market and may need to be modified (e.g., re-
optimized) or abandoned.
There are two optional Monte Carlo analyses that can be performed. The first option
calculates the probability that the account will be X% lower after N trades. For example, X
might be 25, and N might be 10. This would calculate the probability that the account equity
would be 25% lower after the first 10 trades. Note that this is not the same as a maximum
drawdown of 25% within the first 10 trades but rather the probability that at the end of 10
trades, the equity will be 25% lower.
The second option calculates the probability that the account will be X% higher after N trades.
For example, you might calculate the probability that the account will be 50% higher after 30
trades. Note that you must have at least N trades in the current sequence to generate results for
these options. In other words, if you want to know the probability of the account being 50%
higher after 30 trades, for example, you need at least 30 trades in your trade sequence. If your
trade list contains too few trades, you can increase the size of your trade sequence using one
of the methods discussed in Chapter 6, Monte Carlo Analysis, Overview.
The next option affects the dependency analysis. In addition to performing the dependency
analysis (runs test) over all trades in the current sequence, the runs test can optionally be
performed over a sliding window of trades, N trades in length. To add this analysis, check the
box and enter the value for N. The analysis will repeat the runs test over a window of trades N
trades in length, moving the window one trade forward each time. For example, if there are
100 trades, and N = 30, the first runs test will be conducted over trades 1 - 30. The next runs
test will be over trades 2 - 31, the third over trades 3 - 32, etc. The last runs test will be
performed over trades 71 - 100. The results for each runs test will be displayed in the
Dependency tab of the Performance Results window. Also see Chapter 9, Trade Dependency,
Overview.
The next section is where you enter the inputs for the statistical significance test. Enter the
number of rules and/or restrictions imposed by the trading system or method, and select the
confidence limit for the average trade calculation. See Chapter 10, Significance Testing, for
more information.
Finally, this tab allows you to enter a value for the risk-free interest rate used in calculating
the Sharpe ratio. The interest rate is a monthly rate, not an annual rate. See Chapter 12,
Viewing the Results, Performance Results, for the definition of the Sharpe ratio.
38
Portfolio Settings
To enter the basic settings for a portfolio (.msaport) document, select the Setup command of
the Portfolio menu. The Portfolio Setup window has two tabs, Market Systems and Settings,
described below.
The check box at the bottom of this tab is used to automatically reload the chart data at
specified intervals. If this box is checked, the program will reload the trade data from the
trades files for each market system at every specified number of hours, minutes, and seconds.
For example, if you entered 5 in the box for seconds, with zero in the other boxes, MSA
would reload the chart data every five seconds. This is intended for day traders who have set
up their trading software to update the trades file after each trade. For example, a system
written for TradeStation could use the WriteTrades function included with MSA for this
purpose.
Settings tab
The Account Settings tab, shown below, allows you to set basic options related to your trading
account, such as the starting account equity value, and options for Monte Carlo analysis,
dependency analysis and the significance test. At the top of the page, you can enter the
starting account size in currency units (e.g., dollars). The starting account size is used to begin
the equity curve calculation. This is the amount of money in the trading account at the start of
the simulation. The starting account size must be greater than zero to generate an equity curve.
39
You can also select the locale for your trading account on this tab. The locale determines the
currency unit used for display purposes (dollar, Yen, Euro, etc.) as well as the number format.
The next section of this tab presents options and settings for Monte Carlo analysis. The
number of samples used in performing the Monte Carlo calculations can be entered here. The
default is 500 samples. Choosing more than this will provide more accurate results but will
slow down the analysis proportionally to the number of samples; twice as many samples will
take twice as long, for example. You can also select the probability at which the Monte Carlo
results are recorded. The default is 95%. Any value from 50% to 100% can be entered. This is
the probability that is displayed in the Monte Carlo Results window. Also see Chapter 6,
Monte Carlo Analysis, Overview.
You can choose between two types of Monte Carlo analysis. Selecting "Include all trades in
MC analysis" will perform a standard Monte Carlo analysis based on randomizing the trade
order. Following the analysis, the equity curve plot will display four lines: the current
sequence of trades, the equity curve at the specified confidence level, the equity curve at the
lower confidence level (100 minus the specified confidence), and the equity curve at 50%
confidence.
If you choose "Predict equity curve over last N trades", where N is the number entered in the
edit box, the trades prior to the last N trades will be randomly sampled (with replacement) to
extrapolate the equity curve over the last N trades based on the prior trades. As with the other
option, four equity curves will be displayed, this time over the last N trades: the current
40
sequence and the curves at high, low, and median confidence. This feature can be used to
detect when the portfolio is underperforming based on the prior history. In particular, if the
current sequence is below the predicted curve at high confidence (i.e., the lower curve), one or
more of the strategies in the portfolio may be out of sync with the market and may need to be
modified (e.g., re-optimized) or abandoned.
There are two optional Monte Carlo analyses that can be performed. The first option
calculates the probability that the account will be X% lower after N trades. For example, X
might be 25, and N might be 10. This would calculate the probability that the account equity
would be 25% lower after the first 10 trades. Note that this is not the same as a maximum
drawdown of 25% within the first 10 trades but rather the probability that at the end of 10
trades, the equity will be 25% lower.
The second option calculates the probability that the account will be X% higher after N trades.
For example, you might calculate the probability that the account will be 50% higher after 30
trades. Note that you must have at least N trades in the current sequence to generate results for
these options. In other words, if you want to know the probability of the account being 50%
higher after 30 trades, for example, you need at least 30 trades in your trade sequence. If your
trade list contains too few trades, you can increase the size of your trade sequence using one
of the methods discussed in Chapter 6, Monte Carlo Analysis, Overview.
The next option affects the dependency analysis. In addition to performing the dependency
analysis (runs test) over all trades in the current sequence, the runs test can optionally be
performed over a sliding window of trades, N trades in length. To add this analysis, check the
box and enter the value for N. The analysis will repeat the runs test over a window of trades N
trades in length, moving the window one trade forward each time. For example, if there are
100 trades, and N = 30, the first runs test will be conducted over trades 1 - 30. The next runs
test will be over trades 2 - 31, the third over trades 3 - 32, etc. The last runs test will be
performed over trades 71 - 100. The results for each runs test will be displayed in the
Dependency tab of the Performance Results window. Also see Chapter 9, Trade Dependency,
Overview.
The next section is where you enter the inputs for the statistical significance test. Enter the
number of rules and/or restrictions imposed by the trading system or method, and select the
confidence limit for the average trade calculation. See Chapter 10, Significance Testing, for
more information.
Finally, this tab allows you to enter a value for the risk-free interest rate used in calculating
the Sharpe ratio. The interest rate is a monthly rate, not an annual rate. See Chapter 12,
Viewing the Results, Performance Results, for the definition of the Sharpe ratio.
Chapter 5
Position Sizing
Overview
Position size is the number of shares or contracts bought or sold for a given trade. If your
position size is too large, a string of losses could force you to stop trading. With the built-in
leverage of futures, trading too many contracts can even cause you to lose more money than
you have in your account. On the other hand, if your position size is too small, you'll be
underutilizing your account equity, and your performance will suffer. Finding the proper
balance is a part of good money management, and most experts agree that money
management is one of the most critical aspects of trading.
In Market System Analyzer (MSA), the position sizing method for a market system is selected
using the Position Sizing command of the Analysis menu. For a portfolio, the position sizing
methods for the market systems comprising the portfolio are selected using the Position
Sizing command on the Portfolio menu. See Chapter 14, Menu Commands, for the specifics
of each Position Sizing command.
With each position sizing method available in MSA, except for fixed size and constant value
position sizing, the number of contracts increases as profits accrue and decreases as the equity
drops during a drawdown. Position sizing methods that use this approach are known as
antimartingale methods. Antimartingale methods take advantage of the positive expectancy of
a winning trading system or method. If you have an "edge" with your trading (i.e., your
trading method is inherently profitable), you should use an antimartingale method, such as
those listed above. The alternatives, known as martingale methods, decrease the amount at
risk after a win and increase the amount at risk after a loss. A commonly used example is
"doubling down" after a loss in gambling. Martingale methods are often used by gamblers,
who trade against the house's advantage.
Provided you have a profitable trading method, antimartingale methods are always preferable
over the long run because they're capable of growing your trading account geometrically.
However, it's sometimes possible to lower your risk by taking advantage of patterns of wins
and losses, similar to martingale methods. MSA offers two options for doing this: dependency
rules and equity curve trading. Both of these methods adjust the position sizing while
maintaining the selected position sizing method. While martingale methods are not
recommended, these adjustments to the antimartingale methods can sometimes prove
beneficial.
When a position sizing method is applied in MSA, the equity curve in the main chart uses that
method to accumulate the equity from trade to trade to simulate continuous trading over that
series of trades. This approach is intended for evaluating market systems and position sizing
methods. However, a different approach is needed for trading on a day to day basis, where it's
necessary to determine the number of shares/contracts for the next (upcoming) trade. In MSA
this is referred to as real time position sizing (see Real Time Position Sizing, below). This
capability is provided with the Trade Size command (Analysis menu for market systems;
Portfolio menu for portfolios), which is a kind of position sizing calculator. You can use the
Trade Size command to determine the position size for the next trade based on your current
account equity and applying the currently selected position sizing method, parameters, and
related settings.
42
Regardless of the position sizing method chosen, the number of shares or contracts in MSA is
limited by the margin requirements, provided margin data have been entered on the Analysis
Setup window. This insures that the number of shares or contracts could actually be traded
with a real money account. To turn off this limit, enter a value of zero for the futures margin
or stock margin percentage. The position size is also limited to the trade size limit specified on
the Account Settings tab of the Analysis Setup window.
When applying position sizing to a portfolio, MSA uses the settings retrieved from the
market-system documents unless a setting made via the Portfolio menu overrides a market-
system setting.
For information on applying the position sizing methods of MSA within TradeStation
strategies, see the Appendix: Position Sizing Code for TradeStation.
None
The default position sizing method in MSA is “None.” This is the first method listed on the
Position Sizing Method window. In this case, the position size is taken directly from the trade
size field of the input data. If the trade size was not provided in the input data, the default
trade size entered on the Analysis Setup window is used.
Fixed Size
This is the simplest method of position sizing. With this method, you simply choose the
number of shares or contracts, and that number is used for each trade. This option is included
because (1) it provides a good baseline for comparison to more sophisticated position sizing
methods, and (2) many traders are comfortable trading a fixed lot size.
The Monte Carlo analysis feature of MSA can be used to provide a credible prediction of
future performance with a fixed position size. Suppose, for example, that you only want to
increase the lot size after your account equity has doubled. One of the Monte Carlo options
(available on the Options tab of the Analysis Setup window) will estimate the probability that
the account equity will double after, say, 50 trades. You could also use the position sizing
optimization feature with fixed size position sizing to determine the number of shares or
contracts that maximizes your net profit, for example, subject to a limit on the maximum
drawdown.
Constant Value
With constant value position sizing, each position is sized so that it has a specified value, such
as $1000 per trade. This method can be used when you want to allocate a specified amount of
equity to each trade. The constant value method will determine the number of shares/contracts
corresponding to your specified amount. For example, if you plan to purchase a stock at a
price of $25 and you want to spend $35,000, you would trade 35000/25 or 1400 shares. In this
case, the constant value amount is 35000; each trade will be sized so that the position value is
$35,000.
As with fixed size position sizing, this method does not increase position size based on equity.
The position size will vary only with the price of the instrument being traded. Also note that
this method requires the entry price for each trade.
43
As another example, suppose the trading vehicle is stocks, the option to trade in units of 100
shares has been selected, and the account equity is $30,000. If the dollar amount of equity is
$6,000 per unit, then you would trade five units or 500 shares. If the position size calculated in
this manner is fractional, the number is rounded down to the nearest integer. For example, for
a fixed dollar amount per contract of $4,000 and an account equity of $25,000, the program
would calculate 25,000/4,000 = 6.25, which rounds down to six contracts.
It's important to understand that the calculation for the position size is performed prior to each
trade using the current value of account equity. For example, if you start with an account size
of $10,000 and there are several winners in a row, you may have, say, $15,000 in the account
after the 10th trade. For the 11th trade, the position size calculation is based on the account
balance of $15,000. As with all position sizing methods in MSA (except fixed size and
constant value), the number of shares or contracts increases with higher account balances and
decreases as the equity drops during a drawdown.
Percent Volatility
The percent volatility method sizes each trade so that the value of the volatility, as represented
by the average true range (ATR), is a specified percentage of account equity. This method is
attributable to Van K. Tharp. See, for example, his book "Trade Your Way to Financial
Freedom," 2nd ed., McGraw-Hill, New York, 2007, pp. 426-8.
As an example, consider a futures trading system where the ATR is 7.2 points, and the value
of each point is $50. The ATR values can be calculated over any period you choose and are
read in with the trade data using the ATR data input field. With a specified volatility
percentage of 4% and account equity of $20,000, the position size for the next trade would be
0.04 x 20000/(50 x 7.2) or 2.22. The result is 2 contracts for the next trade.
TradeStation users can use the WriteTrades function, discussed in the previous chapter, to
write out the ATR value corresponding to each trade.
Kelly Formula
The Kelly formula is a specialized form of fixed fractional position sizing, described below,
which uses an approximate formula – the Kelly formula – to determine the fixed fraction that
maximizes the equity growth rate. Fixed fractional position sizing risks a specified fraction of
account equity on each trade. The Kelly formula specifies a particular value of the fixed
fraction. This “Kelly f value” is given by the following equation:
Fk = ((WL + 1) * Pw – 1)/WL
where WL is the ratio of the average winning trade to the average losing trade and Pw is the
probability of a winning trade.
44
For example, if the average winning trade is $300, the average losing trade is $400, and the
percentage of winning trades is 65%, the Kelly f value would be ((0.75 + 1) * .65 – 1)/0.75 or
0.183. This means that 18.3% of the account would be risked on each trade.
To determine the position size, the trade risk is assumed to be equal to the largest historical
loss. For example, if the largest loss experienced by the system in question was $1,200 trading
one contract, and the account equity was $35,000, then 18.3% of $35,000 is $6,405. This is
the amount to risk on the trade according to the Kelly formula. With a trade risk of $1,200,
this means we can trade 6405/1200 or 5 contracts.
MSA automatically calculates the Kelly f value for the current sequence of trades. The value
is displayed in the Position Sizing window in the Parameters section when the Kelly formula
is selected from the list of position sizing methods.
Fixed Fractional
The idea behind fixed fractional position sizing is that the number of shares or contracts is
based on the risk of the trade. Fixed fractional position sizing is also known as fixed risk
position sizing because it risks the same percentage or fraction of account equity on each
trade. For example, you might risk 2% of your account equity on each trade. Fixed fractional
position sizing has been written about extensively by Ralph Vince. See, for example, his book
"Portfolio Management Formulas," John Wiley & Sons, New York, 1990.
The risk of a trade is defined as the dollar amount that the trade would lose per contract/share
if it were a loss. Commonly, the trade risk is taken as the size of the money management stop
applied, if any, to each trade. If your system doesn’t use protective (money management)
stops, the trade risk can be taken as the largest historical loss per contract/share. This was the
approach Vince adopted in his book Portfolio Management Formulas.
As an example, consider a stock trading system that uses a 2 point stop. It might enter long at
a price of 48 with a sell stop at 46, for example. The risk per share would be $2. With a fixed
fraction of 5% and account equity of $20,000, fixed fractional position sizing would risk 0.05
* 20000 or $1,000 on the next trade. Since the risk per share is $2, this means 1000/2 or 500
shares would be purchased.
Fixed fractional position sizing is often used with leveraged instruments, such as futures. It’s
one of the only position sizing methods that directly incorporates the trade risk (also see the
Profit Risk method).
Optimal f
Like the Kelly formula, optimal f position sizing is a specialized form of fixed fractional
(fixed risk) position sizing. Optimal f position sizing uses the fixed fraction that maximizes
45
the geometric rate of equity growth. This method was developed by Ralph Vince (see
reference in previous section) as a more accurate version of the Kelly formula. Unfortunately,
optimal f has many of the same drawbacks as the Kelly formula. Namely, the optimal f value
often results in drawdowns that are too large for most traders to tolerate. As with the Kelly
formula, the position size based on the optimal f is often so high that it’s limited by margin
requirements.
The optimal f value is calculated according to an iterative procedure that maximizes the
geometric growth rate for the current sequence of trades. MSA performs this calculation
automatically and displays the resulting optimal f value on the Position Sizing window under
Parameters when the Optimal f method is selected. The calculation for the position size is the
same as for the Kelly formula except that the optimal f value is used in place of the Kelly f
value. The trade risk is taken as the largest historical loss per share/contract.
As with the Kelly formula, optimal f position sizing is included primarily for educational
purposes. As a practical alternative to optimal f, consider using the optimization feature of
MSA with fixed fractional position sizing. Select rate of return as the optimization parameter
to maximize, and check the box for applying a limit to the maximum allowable drawdown.
Optimize using Monte Carlo analysis to find a much smaller and therefore less risky fixed
fraction than optimal f.
As an example, consider a futures trade where the risk of the upcoming trade is $300 per
contract. This amount might correspond to the size of the money management stop that will be
used during the trade or it might be the largest loss per contract that the trading method has
ever produced. Now suppose that the trading account started with a balance of $25,000 and is
currently at a value of $45,000 (a total closed trade profit of $20,000). The percentages for the
profit risk method might be 2% of initial equity and 5% of profits. This means that the total
amount to risk on the trade would be 0.02 x 25000 + 0.05 x 20000 or $1,500. Since the trade
risk is $300 per contract, the number of contracts to trade is 1500/300 or 5 contracts.
Compared to fixed fractional position sizing, the profit risk method is sometimes more
convenient because it separates the account equity into initial equity and closed trade profit.
The percentage applied to the initial equity provides a baseline level of position sizing
independent of trading profits. Note that if both percentages are the same, the profit risk
method will produce the same result as the fixed fractional method.
If the optimization feature of Market System Analyzer is used with the profit risk method,
only the parameter for the percentage of profits will be optimized. The parameter for the
percentage of the initial equity will be unchanged by the optimization.
Fixed Ratio
In fixed ratio position sizing the key parameter is the delta. This is the amount of profit per
share/contract/unit to increase the number of shares/contracts/units by one. A delta of $3,000,
for example, means that if you're currently trading one contract, you would need to increase
46
your account equity by $3,000 to start trading two contracts. Once you get to two contracts,
you would need an additional profit of $6,000 to start trading three contracts. At three
contracts, you would need an additional profit of $9,000 to start trading four contracts, and so
on.
Fixed ratio position sizing was developed by Ryan Jones in his book "The Trading Game,"
John Wiley & Sons, New York, 1999. Based on an equation presented by Jones, it's possible
to derive the following equation for the number of contracts in fixed ratio position sizing:
where N is the position size, N0 is the starting position size, P is the total closed trade profit,
and delta is the parameter discussed above. The carat symbol (^) represents exponentiation;
that is, the quantity in parentheses is raised to the power following the carat (x^2 is “x
squared; x^0.5 is “square root of x”).
A few points are worth noting. The profit, P, is the accumulated profit over all trades leading
up to the one for which you want to calculate the number of shares/contracts/units.
Consequently, the position size for the first trade is always N0 because you always start with
zero profits (P = 0). The account equity is not a factor in this equation. Changing the starting
account size, for example, will not change the number of shares/contracts/units, provided
there is enough equity to avoid dropping below zero.
The trade risk is also not a factor in this equation. If trade risks are defined for the current
sequence of trades, they will be ignored when fixed ratio position sizing is in effect. All that
matters is the accumulated profit and the delta. The delta determines how quickly the
shares/contracts/units are added or subtracted. If the “trade in units” option is selected, delta
will be the profit per unit to increase the number of units by one. For stock trading, without
the trade-in-units option, the delta will be the profit per share to increase the number of shares
by one.
Note that the equation above is applicable only to the case where a single delta is used for
both increasing and decreasing the number of shares/contracts. MSA allows you to decrease at
a different rate. This is accomplished by specifying a delta fraction for decreasing. The delta
fraction is multiplied by the original delta to determine the delta for decreasing the position
size. The delta fraction is set to the value 1.0 by default, which implies the two deltas will be
the same.
If a delta fraction less than 1.0 is entered, the levels of increase and decrease will be closer
together, which will cause the position size to decrease more frequently in drawdowns as the
equity drops. This will provide more protection from drawdowns but less ability to recover. If
a delta fraction greater than 1.0 is entered, the level of decrease will be farther from the level
of increase, so the position size will not drop as quickly or change as often during a
drawdown. This will provide less protection during drawdowns but make is easier to recover.
Note that if the optimization feature of MSA is used with fixed ratio position sizing, only the
delta parameter will be optimized. The delta fraction will be unchanged by the optimization.
Generalized Ratio
As the name suggests, generalized ratio position sizing is a generalized version of fixed ratio
position sizing. Generalized ratio position sizing uses an additional parameter – the exponent
– to alter the characteristics of the fixed ratio equation. Generalized ratio position sizing is
unique to MSA.
47
where N is the number of shares/contracts/units, P is the total closed trade profit, m is the
exponent, which must be greater than or equal to zero, and delta is as described for the fixed
ratio method. The carat symbol (^) represents exponentiation; that is, the quantity in
parentheses is raised to the power of m.
With an exponent of ½, the generalized ratio method is the same as the fixed ratio method
with an initial position size of one. With exponent values less than ½ the position size
increases more slowly with increasing profits than with the fixed ratio method. With
exponents greater than ½, the position size increases more quickly than with the fixed ratio
method. An exponent value of one provides the same proportionality as the fixed fractional
method. An exponent value of zero gives one share/contract/unit for each trade.
The number of shares/contracts/units always starts at one with generalized ratio position
sizing. This can be seen in the equation above. If the profit, P, is zero, N is equal to 1. For this
reason, generalized ratio position sizing is more suitable for smaller accounts. Also, for stock
trading, the “trade in units” option should be selected so that the initial number of shares will
be equal to one unit. If the unit size is 100 shares, for example, the generalized ratio method
will start with 100 shares.
Note that if the optimization feature of MSA is used with generalized ratio position sizing,
only the delta parameter will be optimized. The exponent, m, will be unchanged by the
optimization.
Margin Target
Margin target position sizing sets the size of each position so that the chosen percentage of
account equity will be allocated to margin. For example, if you choose a margin target of
30%, then 30% of the account equity will be allocated to margin. For futures trading, the
trading margin is specified on a per-contract basis. The margin requirement for trading one
contract of the E-mini S&P futures might be $4,000, for example. For an account equity value
of $30,000, a 30% margin target would mean that 0.3 x 30,000 or $9,000 would be allocated
to margin. With a margin requirement of $4,000, the number of contracts would be 9000/4000
or 2 contracts (rounded down from 2.25). In other words, a position size of two contracts
requires a margin amount ($8,000) that is as close to 30% of equity as possible without
exceeding that target.
For stock trading, the margin requirement is calculated as a percentage of the purchase price
of the position. If the margin requirement is 100% (no leverage), you need to pay the full
amount of the trade. For example, a stock trade that enters at a price of $23 would require $23
per share. However, a typical retail margin account in the US can be margined up to 50%,
which mean that the margin requirement for a $23 stock would be only $11.5 per share. If the
margin target is, say, 40%, and the account equity is $25,000, then $10,000 should be
allocated to margin (i.e., 0.4 x 25000). For a $23 stock and a margin requirement of 50%, you
would trade 10000/11.5 or 869 shares. In other words, 869 shares would require margin of
about $10,000, which is 40% of the account equity of $25,000.
48
If the margin is undefined or the entry price is undefined for stocks, the position size for the
margin target method will default to the maximum allowable position size, as defined on the
Account Settings tab of the Analysis Setup window.
Leverage Target
The leverage target position sizing method sets the position size so that the leverage of the
resulting position matches the selected target. Leverage is defined as the ratio of the value of
the position to the account equity. For example, if 1000 shares of a $30 stock are purchased
with a $25,000 account, the leverage would be $30,000/$25,000 or 1.2. Leverages greater than
1.0 imply margin percentages less than 100%. A margin percentage of 50%, for example, is
equivalent to a leverage of 2 (“2 to 1” or “2:1”). For stocks, the relationship between the
minimum margin requirement in percent and the maximum allowable leverage is provided on
the Account Settings tab of the Analysis Setup window.
This method requires the entry price and, for futures, the point value (defined on the Input
Data tab of the Analysis Setup window). If the entry prices have not been defined or the point
value for futures has not been entered, the position size will be zero.
Percent of Equity
This method is intended primarily for stocks. The number of shares is chosen so that the value
of the position is equal to the selected percent of account equity. For example, if the percent of
equity is 40%, the position size will have a value equal to 40% of the account equity. If the
account equity is $30,000, the position would have a value of 0.4 x 30000 or $12,000. If the
share price is $25, the position size would be 12000/25 or 480 shares. In other words, a
position size of 480 shares at $25 per share has a value of $12,000, which is 40% of the equity
value of $30,000.
As with the leverage target method, this method requires the entry price and, for futures, the
point value. If the required data are not available, the position size will be zero.
Each subsequent contract is added when the equity increases by 150% of the worst-case
drawdown. This insures that you always have enough equity to avoid losing everything even
if the worst-case drawdown repeats itself. In fact, even if the drawdown is 150% of the
historical worst-case value and it happens at the most inopportune time (which is immediately
after adding a new contract), you would still be left with enough equity to cover the margin
for one contract. In MSA, the percentage of maximum drawdown, such as William’s
recommended value of 150%, is selected by the user. You can set this percentage to any
positive value.
Although originally devised for futures trading, this method works equally well for stocks. If
the entry price for a stock trade is not available or the margin has not been specified, the
required equity for the first share/contract/unit will be zero. In the unlikely case that the
49
historical sequence of trades has zero drawdown, the position size will default to the
maximum allowable value specified on the Account Settings tab of the Analysis Setup
window.
Maximum Possible
This method sets the position size to the maximum possible number of shares or contracts
based on margin requirements. In other words, you’ll trade as many contracts or shares as you
can afford.
For example, consider a futures trade where the margin requirement for one contract is $3000.
For a $25,000 account, the maximum possible number of contracts is 25000/3000 or eight
contracts. For a stock trade with an entry price of $14, a margin requirement of 50% and an
account size of $35,000, the maximum possible number of shares would be 5000 shares
(35000/(0.5 x 14)).
If the margin, or the entry price if trading stocks, has not been defined, this method defaults to
the maximum allowable position size specified on the Account Settings tab of the Analysis
Setup window.
The basic idea is to either trade more or fewer shares or contracts when the equity curve
crosses above or below its moving average. Three rules for implementing this are available.
The first rule, "Stop trading when equity crosses above/below moving average; resume trading
on crossover in opposite direction" is the most basic and commonly used method. If this rule
is selected, you must choose either "above" or "below" to indicate whether to stop trading
50
when equity crosses above or below the moving average. Choose "below" if your system or
method tends to produce streaks of wins and losses, so that when it starts to lose, it's best to
stop trading until it starts winning again. Choose "above" if your system or method tends to
"revert to the mean"; i.e., after several wins, it starts to lose, and vice-versa. Note that the
dependency analysis can be used to determine if your system has either of these tendencies
with statistical significance. If the first rule is chosen, the other two rules are deactivated.
The second and third rules produce a more subtle change in position sizing than the first one.
Whereas the first rule starts and stops trading on crossovers of equity with the moving
average, the second and third rules reduce or increase the position size on moving average
crossovers. Selecting the second rule will increase the position size for the currently selected
method by X% when the equity crosses above/below the moving average. Selecting the third
rule will decrease the position size by Y% when the equity crosses above/below the moving
average. The second and third rules can be selected together or one or the other can be
selected alone. The increase or decrease in the position size is relative to the current value of
position size.
If both rules are selected together, make sure that if one rule uses "above", the other uses
"below." For example, the second rule might be to increase the position size 50% when equity
crosses above the moving average. The third rule might be to decrease the position size by
30% when equity crosses below the moving average. In this case, the parameter is either 50%
higher or 30% lower than the baseline value. Alternatively, you can alter the position size on
crossovers in one direction but not the other by selecting only one of the second and third
rules. For example, if you only select the second rule with a percentage value of 40% and
select "above," then the position size will be 40% higher on crossovers above the moving
average and will return to the baseline value on crossovers below the moving average.
Under “options” on the Equity Curve Crossovers tab, you can enter the length of the moving
average of the equity curve and the type of moving average. The length is the number of
trades used to calculate the moving average. MSA has four optional moving average types:
simple, exponential, weighted, and TRIX (triple exponential). There is also an option to show
the moving average on the chart. The length entry and the option to show the moving average
are also available through the Format Chart command.
To begin, enter the current value of your account equity in the first box. If fixed fractional
(fixed risk) or the profit risk position sizing method has been chosen, enter the trade risk in the
second box. If the “trade in units” option has been selected, the trade risk will be the risk per
unit; e.g., the risk per 100 shares. As explained previously, the trade risk is the dollar amount
the trade would lose per share/contract if it were a loss. This is most often determined from
the placement of a money management stop order or from the size of the largest historical
loss. If required by the selected position sizing method, enter the market price or expected
entry price of the trading vehicle and the average true range (ATR) on the bar prior to entry.
Once these data have been entered, click the “Calculate” button in the Results section or press
the Enter key on your keyboard. The number of shares or contracts and the required margin
will be displayed. You can enter different values for the account equity and trade risk (if
applicable) to recalculate the results. Click Close to close the window when finished.
The calculations are performed using the position sizing method, parameters, and settings
currently in effect. These settings include the options on the Analysis Setup and Position
Sizing windows, including the equity curve crossover rules, as well as the dependency rules.
The calculation is performed as if the trade in question was the next trade in the current
sequence. That is, the trade for which the position size is calculated is assumed to be the trade
that immediately follows the last trade in the current sequence. If, for example, the negative
dependency rule has been selected -- "skip the next trade after a win, take the next trade after a
loss" -- and the last trade in the current sequence is a win, Trade Size will calculate zero
shares/contracts for the next trade. The calculation may also produce a zero position size if the
equity curve crossover rule is in effect (depending on the selected rule and the equity curve) or
if the entered value of equity is so low that the position size rounds down to zero from a
fraction.
Trade Size can also be used as a stand-alone position sizing calculator. In this mode, simply
run MSA without opening a .msa file or entering any data into the program. With no data in
the program, select your position sizing method and options from the Analysis menu then
press F11 (or select Trade Size from the Analysis menu) to open the Trade Size window.
Enter the data and click “Calculate,” as explained above.
52
In most cases, the best way to use this feature is to maintain a .msa file containing an up-to-
date list of the trades from the system or method of interest. Use MSA to analyze the trades
and optimize the position sizing method, preferably limiting the analysis to a range of trades
and saving the rest for out-of-sample testing. Select any other rules, such as dependency rules
or equity crossover rules, and verify the analysis with out-of-sample testing and Monte Carlo
analysis. At this point, assuming the last trade in the current sequence is the most recent trade
from your system or method, you can run Trade Size with the optimized position sizing
parameters and rules to calculate the number of shares or contracts for the next trade. Enter
each new trade into MSA to make sure any selected dependency or equity crossover rules
reflect the actual trade history. Keeping the list of trades up-to-date also enables you to re-
optimize as frequently as after each trade if desired. You should maintain a separate .msa file
for each market system you follow with the program in order to store all your analysis
settings.
To use this command, enter the current value of your account equity in the space provided.
Then enter the data for each market system in the boxes on the left-hand side of the window.
Use the Next MS button to move to the next market system until the data have been entered
for each market system. Finally, click the “Calculate Position Sizes” button. The results are
displayed in the list above the calculate button. The results include the name and number of
the market system, the trade risk per share/contract/unit if applicable, the calculated position
size for the next trade, and the margin or cost for the indicated position size. The total margin
or cost for the portfolio is also shown. Note that the word “margin” is typically used with
futures while “cost” is used with stocks. This reflects the fact that futures trades require a
margin deposit, whereas stocks are typically bought or sold based on the position’s value.
Most of the required data, such as the trade risk and the entry price, are the same as described
above for the Trade Size command for market systems. However, for portfolios, it’s also
necessary to account for any open positions. This is the purpose of the check box “Open trade.
Position size:” If there is an open position for the market system, the size of the position
should be entered here. If no entry is expected for the market system, it can be excluded from
the calculations by checking the box “No new entry; exclude MS”. This will ensure that no
equity is allocated to this market system when determining the position sizes for the other
market systems.
Chapter 6
Monte Carlo Analysis
Overview
Monte Carlo analysis is a computational technique for assessing the impact of random
variation in a simulation model's parameters. In Monte Carlo analysis, the random variables of
a model are represented by statistical distributions, which are randomly sampled to produce
the model's output. The output is therefore also a statistical distribution. Compared to
simulation methods that don't include random sampling, the Monte Carlo method often
produces more useful results, which tend to be more conservative and often more accurate
when used as predictions.
In Market System Analyzer (MSA), the trade distribution, as represented by the list of trades,
is sampled to generate a trade sequence. Each such sequence is analyzed, and the results are
sorted to determine the probability of each result. In this way, a probability or confidence
level is assigned to each result. Without Monte Carlo analysis, the standard approach for
calculating the historical rate of return, for example, would be to analyze the current sequence
of trades using, say, fixed fractional position sizing. It might be found that the rate of return
over the sequence was 114%. With Monte Carlo analysis, on the other hand, hundreds or
thousands of different sequences of trades are analyzed, and the rate of return is evaluated at a
specified probability. For example, the rate of return as determined by Monte Carlo analysis
might be 83% with 95% confidence. This means that of all the thousands of sequences
considered, 95% had rates of return greater than or equal to 83%.
The Monte Carlo analysis for a market system in MSA is performed when the Monte Carlo
Analysis command is selected from the Analysis menu. For portfolios, the same command is
available on the Portfolio menu. The analysis is performed on the current sequence of trades
using the number of samples entered in the Options tab of the Analysis Setup window (or
Settings tab of the Portfolio Setup window for portfolios). In this context, "sample" means a
randomly selected sequence of trades. The default is 500 samples, which means that the
Monte Carlo results will be based on 500 random trade sequences. The results in the Monte
Carlo Results window will be displayed at the confidence level selected on the Analysis Setup
(Portfolio Setup for portfolios) window.
Note: In MSA version 3.5 and above, the Monte Carlo analyses for both market systems and
portfolios use parallel processing algorithms that are designed to fully utilize all cores of a
multi-core computer to maximize processing speed.
There are two types of Monte Carlo analyses available in MSA. As shown on Analysis Setup,
the options are "Include all trades in MC analysis" and "Predict equity curve over last N
trades".
list of trades without regard to whether or not the trade had already been selected. In selection
with replacement, a trade could occur more than once in the new sequence.
The benefit of selection without replacement is that it exactly duplicates the probability
distribution of the input sequence, whereas selection with replacement may not. The drawback
to selection without replacement is that the randomly sampled sequences are limited to the
number of trades in the input sequence. If you have a short sequence of trades (say, less than
30 trades), this may limit the accuracy of certain calculations, such as the drawdown.
Fortunately, the data manipulation features of MSA provide a way to avoid this problem.
If you have a small sample of trades to analyze, it's recommended that you increase the size of
your trade list using one of two methods:
1. Import the list of trades multiple times, appending the imported trades to the existing ones
each time. When the list of trades is long enough, such as 100 trades, randomize the
sequence several times before performing your analysis. If you entered the trades
manually rather than through the import command, export the trades you entered to create
a file that can then be imported back in.
2. Use the statistical properties of your small sample, as given in the Performance Results
window, to create a larger series of trades using the Create Trades From Statistics
command.
The first method is similar to random selection with replacement with the added benefit that
the final list of trades will have the same statistical properties as the original list. The second
method introduces more randomness into the trade sequence, which may be preferable given
that trades encountered in the future will likely be different than those of the original
sequence. Either of these methods will provide you with a sequence of trades that is as long as
needed to generate meaningful results.
When performing the Monte Carlo analysis for a portfolio, MSA randomizes the trade
sequence for each market system separately before combining the trade sequences into the
portfolio equity curve. This means that any correlations between market systems will be lost
during the Monte Carlo analysis. If your analysis or position sizing settings depend on the
correlations between market systems, a portfolio Monte Carlo analysis may not generate
meaningful results. On the other hand, by removing the correlations, a more conservative
result may be generated.
In addition to displaying summary results in the Monte Carlo Results window, the equity
curve display will be changed following the Monte Carlo analysis so that it displays
probability bands resulting from the analysis. The "Current Sequence" drop-down menu in the
menu bar will change to "Monte Carlo", and four equity curves will be displayed, as shown
below.
The thicker curve in the figure below is the equity curve for the current sequence of trades.
This curve can be changed using the Randomize/Restore commands just like when the
"Current Sequence" option is selected in the menu bar. The upper and lower curves in the plot
are the lower and higher confidence bands, respectively, for the Monte Carlo analysis. For
example, if the confidence level for Monte Carlo analysis is 95%, the lower band will be at
95% confidence, and the upper band will be at 5% confidence (i.e., 100% - 95%). The middle
curve represents the results at 50% confidence.
55
All three curves are calculated trade-by-trade. For example, the equity value at 95%
confidence for trade 100 is the equity value lower than 95% of the Monte Carlo iterations for
that trade; i.e., 95% of the Monte Carlo iterations had an equity value for that trade higher
than the plotted value. In general, increasing the confidence level will increase the width of
the channel -- the distance between the upper and lower bands. Setting the confidence level to
100% implies that all equity curves generated from the Monte Carlo analysis fell between the
two bands. The curve at 50% confidence represents the trade-by-trade median value of the
Monte Carlo iterations. The display can be changed back to the normal equity curve plot by
changing the drop-down menu from "Monte Carlo" to "Current Sequence".
The green envelope shows the range of possible equity curves generated by the Monte Carlo
analysis by sampling from the trades prior to the last N trades in the sequence. As with the
other type of Monte Carlo analysis, this analysis generates three curves: the high confidence is
the user-chosen confidence level, the low confidence level is 100 minus the entered
confidence level, and the middle curve represents 50% confidence (i.e., the median result).
The green envelope is the region between the high and low confidence bands.
56
This envelope represents a prediction for the equity curve over the last N trades. The trades
that actually took place are shown overlaid on the prediction envelope. By comparing the
actual trades to the prediction envelope, this analysis can be used to determine if the trading
strategy or portfolio is still performing within expected bounds. For example, for an individual
market system, if the historical sequence of trades falls outside the lower boundary of the
envelope, the trading strategy may need to be re-optimized, or it may be prudent to stop
trading the strategy. Similarly, for a portfolio, if the equity curve falls outside the lower
boundary of the envelope, there may be a problem with one or more of the market systems in
the portfolio.
Options
There are two optional calculations that can be performed with the Monte Carlo Analysis. To
select these options, select Setup on the Analysis menu and go to the Options tab (or select
Setup on the Portfolio menu and go to the Settings tab). In the Monte Carlo Analysis section,
there are two check boxes for calculating the probability that the account equity will be x%
higher or lower after N trades. The number of Monte Carlo samples and the confidence level
for the Monte Carlo calculations are also selected in this section. Also see Chapter 14, Menu
Commands, Analysis Menu Commands, and Portfolio Menu Commands. The results
generated by a Monte Carlo analysis are described in Chapter 12, Viewing the Results.
Chapter 7
Parameter Studies
Overview
The Parameter Studies feature of Market System Analyzer (MSA) lets you see how the
performance statistics of your system or method vary with the position sizing parameters
available to you. For example, you can plot the rate of return versus the fixed fraction or the
average trade versus the number of contracts. This kind of analysis is sometimes referred to as
sensitivity analysis. It allows you to see how sensitive your results may be to changes in the
position sizing parameter values.
Let's say for example that you use the optimization feature to find the delta value for fixed
ratio position sizing that maximizes the profit factor subject to keeping the drawdown to less
than 30%. Perhaps the optimal delta that results from this optimization is $3200. You could
then bring up the parameter studies window and plot the delta vs. profit factor for delta values
in the range of say, 1000 to 5000. You would want to verify that values near 3200 also
produce good profit factors. If not, then 3200 may not be a good choice, and you could use the
parameter studies plot to find a value where the curve is flatter and therefore less sensitive to
the delta value. You could also plot the drawdown vs. delta to make sure any value of delta
you chose did not exceed your drawdown limit of 30%.
Plotting a Curve
To use the Parameter Studies feature, select Parameter Studies from the Analysis menu.
Parameter Studies are only applicable to market systems, not portfolios. This command brings
up a window with a blank graph, as shown below. The graph will display some basic
instructions about how to create a plot. In general, you need to select the X and Y axis
parameters from the pull down menus near each axis.
58
The X (horizontal) axis pull down menu allows you to select from the following parameters:
Trade Size, Pos Value, Fixed Eqty Amount, Volatility (%), Fixed Fraction (%), Profit Risk
(%), Delta (Fix Ratio), Delta (Gen Ratio), Margin (%), Leverage, % of Equity, and % of Max
DD. These choices correspond to the available position sizing methods that have adjustable
parameters; namely, fixed size, constant value, fixed amount of equity, percent volatility,
fixed fractional, profit risk method, fixed ratio, generalized ratio, margin target, leverage
target, percent of equity, and max drawdown method, respectively.
The Y (vertical) axis pull down menu provides the following choices: Net Profit, Rate of
Return, Ave Trade ($), Ave Trade (%), Profit Factor, RR-DD Ratio (return-drawdown ratio),
Mod Sharpe (modified Sharpe ratio), and Max % DD (maximum percentage drawdown).
These choices correspond to performance measures listed in the Performance Results window.
Once the X and Y axis choices are made, type in the minimum and maximum values for the X
parameter in the boxes labeled "Min X Value" and "Max X Value" near the X axis. The
program provides default values in these boxes based on the X parameter chosen, but a tighter
range is usually preferable. You can also optionally select the number of points to plot along
the curve; the default value is 50 points.
Lastly, you can choose whether to plot the curve using the current sequence of trades, as
shown in the main chart window, or using Monte Carlo analysis. If you choose Monte Carlo
analysis, the performance measure on the Y axis will correspond to the performance measure
listed in the Monte Carlo Results window. For example, the rate of return will be the rate of
return at the confidence level selected for Monte Carlo analysis. Keep in mind that selecting
Monte Carlo analysis will slow down the calculation process considerably. If you choose this
option, it would be prudent to select a relatively small number of data points (e.g., 10) the first
time to see how long the process takes. In many cases, choosing Monte Carlo analysis will
provide smoother plots for the same number of points.
59
After the various inputs and options are selected, click on the button at the bottom of the chart
labeled "PLOT CURVE." The curve will be plotted as it calculates each point. The selections
made in the Parameter Studies window have no effect elsewhere in Market System Analyzer
and are not saved when the window is closed.
Chapter 8
Optimizing Position Sizing
Overview
The optimization feature of Market System Analyzer (MSA) enables you to find the optimal position
sizing parameter values for market systems and portfolios. You can maximize one of seven
performance metrics and add an optional constraint on the worst-case peak-to-valley drawdown. The
optimization can be performed over the current sequence of trades or using Monte Carlo analysis to
randomize the trade sequence.
Optimization Objectives
The optimal position sizing results depend on the performance metric maximized during the
optimization. These are referred to as the optimization objectives. To see the choices
available, select Optimize Position Sizing from the Analysis menu (or the same command
from the Portfolio menu for optimizing a portfolio). This brings up the Optimize Position
Sizing window, as shown below.
The choices for the optimization objective appear in the top left section of the window,
labeled "Maximize…." The same objectives are available for optimizing portfolios. You can
choose to maximize the following performance measures: Net Profit, Rate of Return, Average
Trade, Average Trade (%), Profit Factor, Return-Drawdown Ratio, or Modified Sharpe Ratio.
In addition, the maximum peak-to-valley percentage drawdown can be limited to a specified
value; e.g., 20%. See Chapter 12, Viewing the Results, Performance Results, for a definition
of each performance measure when optimizing over the current sequence of trades. When
61
optimizing using Monte Carlo analysis, see Chapter 12, Viewing the Results, Monte Carlo
Results, for a definition of each performance measure.
When optimizing a market system, the optimization process is applied to whichever position
sizing method is currently selected. Likewise, for portfolios, the optimization process applies
to the position sizing methods currently selected for each market system, as shown on the
Position Sizing window for the portfolio. Each market system may use a different position
sizing method if desired, and the portfolio can mix stocks and futures. The program will
search for the position sizing parameter value(s) that maximizes the chosen objective, subject
to the drawdown constraint, if selected. The following table lists the parameter that is
optimized for each position sizing method.
Notes to table:
1. For the profit risk method, only the percentage of profits is optimized. The percentage of
initial account equity is unaffected by the optimization.
2. For the fixed ratio method, only the delta is optimized. The initial trade size and the delta
fraction are unaffected by the optimization.
3. For generalized ratio position sizing, only the delta parameter is optimized. The exponent
is not changed.
4. The following position sizing methods have no adjustable parameters and cannot be
optimized: None, Kelly formula, Optimal f, and Maximum possible.
While the optimization is ongoing, the top part of the Optimize Position Sizing window will
be dimmed, and the results will be displayed as they are generated in the bottom part of the
window. The corresponding chart window will change to display the message “Optimization
in progress. Please wait…” To cancel the optimization without saving the results, click the
Cancel button at the bottom of the Optimize Position Sizing window. To cancel the
optimization while keeping the best results found up to that point, click the Cancel Save
button. After the optimization process is complete, the summary results will be displayed in
the bottom part of the Optimize Position Sizing window. The complete optimization results
can be displayed in a separate window by clicking the View Full Results button. Provided the
optimization is successful, the chart window will be recalculated to use the optimal parameter
value(s).
Options
There are several available options for optimizing position sizing. These options are available
on the upper part of the Optimize Position Sizing window, whether for market systems or
portfolios. One option is whether to optimize over all trades in the current sequence or using a
sliding window. This option is only available for market-system documents, not portfolios.
62
When optimizing over all trades, the optimization looks for the position sizing parameter
value that optimizes the objective over all trades in the current sequence. In other words, the
optimization objective is calculated based on the performance statistics generated from the
trades shown in the chart window. For example, if the optimization objective is rate of return,
the optimization will try to maximize the rate of return calculated over all trades shown in the
chart window.
The other choice is to optimize over a sliding window of trades. In this case, the user enters
the number of trades in the sliding window, and the optimization is repeated for each window
as it slides forward one trade at a time. For example, suppose there are 100 trades in the
current sequence, and the user enters a sliding window size of 50 trades. The first optimization
will be performed over trades 1 - 50. The optimization window then slides forward one trade,
and the next optimization is over trades 2 - 51. The third optimization will be over trades 3 -
52, and so on until the last optimization is performed over trades 51 - 100.
In a sliding window optimization, an optimal result is obtained for each window. These
optimal position sizing parameter values can be used in plotting the main chart window by
selecting the Position Sizing Method tab in the Position Sizing window under the Analysis
menu. On the Source drop-down menu in the Parameters section, select the option “sliding
window opt, in-sample” or “sliding window opt, out-of-sample.” The former will cause the
chart to be plotted using the optimal sliding window parameter values applied as optimized (in
sample). The latter choice will apply the parameter value optimized over trades n - m to trade
m+1. For example, the parameter value optimized over trades 1 - 50 will be applied to
calculate the number of contracts for trade 51. In this way, you can test the optimization
results "out of sample," without the benefit of hindsight. This is explained further in Chapter
14, Menu Commands, Analysis Menu Commands, Position Sizing Command.
Another option available for optimization is whether to optimize using the current sequence of
trades or Monte Carlo analysis. This option is available for either market systems or
portfolios. Selecting "Current sequence of trades" from the "Optimize using..." section of the
Optimize Position Sizing window instructs the program to perform the analysis calculations
using the current sequence of trades, as shown in the chart window. Alternatively, you can
select "Monte Carlo analysis" to instruct the program to perform the analysis calculations
using Monte Carlo analysis. In this case, the optimization objective will be calculated using
Monte Carlo analysis at the confidence level entered on the Setup window under the Options
tab (Settings tab for portfolios). For example, if a confidence level of 95% has been chosen for
Monte Carlo analysis and the optimization objective is the rate of return, then the optimization
will use the rate of return at 95% confidence as the optimization objective.
There are two different search methods available for optimizing individual market systems.
The default method, which is called the adaptive search method, iteratively subdivides the
interval around the parameter being optimized until the optimal value is found. The alternative
method is called the exhaustive search method. This method divides the search interval into
evenly spaced values and evaluates every value within the interval. In almost all cases, the
adaptive search method will be much faster than the exhaustive method. Consequently, the
adaptive search method is recommended for most optimizations. The exception is when the
optimization is for the number of shares/contracts/units in fixed size position sizing. In this
case, the adaptive search method may fail to find a solution or may take longer than the
exhaustive search method.
For portfolios, there is only one search method. Optimizing a portfolio involves searching for
the best position sizing parameter values for all market systems simultaneously. An
exhaustive search technique would be prohibitively time-consuming in this case.
63
There is one option that is only available when optimizing a portfolio. The option labeled
“Start optimization at…” allows you to set the starting point for the optimization at the current
position sizing values or at values chosen by the program. The former choice starts the
optimization at whichever values are currently selected for calculating the equity curve, as
displayed in the chart window. These values can be changed using the Position Sizing
command of the Portfolio menu. This is often a good choice if you believe the current position
sizing values are close to the optimum.
The latter choice (“Values chosen by program”) randomly selects the parameter value for each
market system. Several randomly chosen sets of parameter values are generated, and the set
that produces the highest value of the objective is selected as the starting point. Because not
all randomly generated values will yield positive results or meet the drawdown constraint (if
selected), some trials will be rejected. As a result, this process can be time-consuming. In
effect, the process of finding the starting point in this manner is an optimization by itself. The
benefit of this approach is that it can often yield results that are unexpected and often quite
different than starting from the current parameter values. In fact, if the results obtained by
starting at the current parameter values are not satisfactory, the recommended approach is to
perform the optimization again starting at values chosen by the program.
Chapter 9
Trade Dependency
Overview
Trade dependency is the characteristic in which one trade depends on the previous trade. For
example, in some trading systems or methods, winning trades tend to follow other winning
trades, and losses tend to follow losses. This is known as positive dependency: wins follow
wins and losses follow losses. In negative dependency, wins tend to follow losses, and losses
tend to follow wins.
Market System Analyzer (MSA) uses a "runs test" to determine if there is any statistically
significant dependency in the current sequence of trades. A runs test determines if the runs of
wins and losses are significantly longer or shorter than can be expected if the trades occurred
in random order. A "run" is simply a consecutive series of wins or losses. For example,
suppose the trade sequence consists of $500, $200, $300, $150, -$750, -$250, $350, $400, -
$500. This series of nine trades consists of two runs of wins and two runs of losses. The first
run of wins is four trades in length, which is followed by a run of two losses. Following that is
a run of two wins and finally a run of one loss.
The runs test is a specialized z test that takes the following form:
where r is the number of runs, W is the number of winning trades, L is the number of losing
trades, X = (2WL)/(W + L), and N is the total number of trades (N = W + L).
The critical value of the z statistic comes from the z, or normal, distribution. With 95%
confidence, for example, the critical value for a two-tailed test is 1.96. So, if the calculated z
statistic is greater than 1.96 or less than -1.96, we would conclude that the number of runs is
significant with 95% confidence. Positive values of z imply more runs than by chance;
negative z values imply fewer runs than by chance.
If there are fewer runs than expected by chance, this implies the runs are longer than expected,
which implies positive dependency (wins follow wins; losses follow losses). If there are more
runs than by chance, this implies the runs are shorter than expected, which implies negative
dependency (wins follow losses and losses follow wins). If the dependency has a high degree
of significance (high confidence level) – e.g., 95% or greater – it may be worth exploiting.
Market System Analyzer allows you to set dependency rules in this case to exploit the
dependency you find (see below).
MSA automatically performs a runs test to analyze trade dependency whenever the current
sequence of trades is analyzed. If the sliding window option has been selected in the Options
tab of the Analysis Setup window (or Settings tab of the Portfolio Setup window for
portfolios), then the runs test is also performed on a sliding window of trades. The results of
the runs test are displayed in the Dependency tab of the Performance Results window (View
menu).
65
To apply one of the dependency rules, select Dependency Rules from the Analysis or
Portfolio menu. This opens the Dependency Rules window, shown below for portfolios. The
same rules are available for individual market systems.
The dependency rules are grouped into three categories: basic rules, consecutive win rules,
and consecutive loss rules. The basic dependency rule choices are as follows:
No dependency. All trades are included. This is the default.
Positive Dependency: Skip trades after a loss until a skipped trade would have been a
winner. This rule can improve trading performance if wins tend to follow wins and losses
tend to follow losses.
Negative Dependency: Skip the next trade after a win; take the next trade after a loss.
This is intended to be used when wins tend to follow losses and losses tend to follow
wins.
The consecutive win rules are as follows:
After X wins in a row, skip the next Y trades. Here, X and Y are entered by the user. This
rule is intended to be used in conjunction with the results of the dependency analysis,
which calculates the average length of runs of wins and losses. For example, if the
average winning run is 3 trades, and average losing run is 2 trades, you might try skipping
the next two trades after three wins in a row.
66
If either of the basic dependency rules is selected, no other rules can be selected. However, if
neither of the basic dependency rules is selected, one rule can be selected from each of the
consecutive win and consecutive loss rule categories, for a total of up to two dependency
rules. For example, you might select the rules “After 4 wins in a row, decrease the position
size by 100 shares” and “After 3 losses in a row, increase the position size by 100 shares.”
As shown in the figure above, the Dependency Rules window for portfolios includes an option
at the bottom of the window to deactivate all dependency rules in individual market systems.
Checking this box will turn off any dependency rules that have been selected in the individual
market systems comprising the portfolio. In this case, the only dependency rules that will
affect the portfolio trading results will be those selected for the portfolio. These rules are
67
applied to the trade sequence for the portfolio, which includes all market systems taken
together. The trades in a portfolio are ordered according to their exit dates.
Chapter 10
Significance Testing
Market System Analyzer (MSA) includes a statistical test to help determine if a trading
system or method has an inherent edge. The test is a type of "significance" test called the
Student's t test, which is applied to the average trade for the current sequence of trades. The
test determines if the average trade is significantly greater than zero at a user specified
confidence level. For example, the test will determine if the average trade is greater than zero
with, say, 95% confidence.
To perform the test, you'll need to enter the number of rules and/or restrictions imposed by
your trading system or method. The number of rules and/or restrictions is used to calculate the
number of "degrees-of-freedom," which is necessary to calculate the t value for the t test.
There needs to be a sufficient number of degrees of freedom to insure that the system is not
over fit to the market. The number of degrees of freedom is the number of trades minus the
number of restrictions. With too few trades, we can't be sure that the profitability of our
system or method is not due to a chance arrangement of trades. The more trades we have, the
greater the number of degrees of freedom and the more confident we can be that our
calculated average profit is not a statistical fluke but a real number that is likely to hold up in
the future.
To count the number of restrictions, Thomas Hoffman (Babcock, Bruce. The Business One
Irwin Guide to Trading Systems. Richard D. Irwin, Inc. 1989, p. 89) suggests examining a
trading system's rules and counting any condition that would change the resulting trades. For
example, suppose you have a trading system that buys when today's close is less than
yesterday's close in an up trend. It defines an up trend as when a shorter moving average is
greater than a longer moving average. For simplicity, let's assume the sell side is the reverse,
and there are no stops. It's a simple stop and reverse system.
We would probably count the moving average cross over condition as three restrictions, one
for the condition itself, and one for each moving average period. The price pattern would be
another restriction for a total of four restrictions for the long side. We would then count four
more for the short side. This would give us eight restrictions in total. If we had, say, only eight
trades, there would be no degrees of freedom, and we shouldn't have any confidence in the
average trade number, even if it were very high. On the other hand, if we had 100 trades, we
would have 92 degrees of freedom, which would give us much more confidence in the
average trade number.
In MSA, the t test is expressed as a confidence interval for the average trade:
CI = t * SD/sqrt(N)
where CI is the confidence interval around the average trade, t is the Student's t statistic, SD is
the standard deviation of the trades, N is the number of trades, and sqrt represents "square
root." The t statistic is retrieved from a look-up table and depends on the number of degrees of
freedom and the user-chosen confidence level.
69
The confidence interval means that the average trade is likely to lie between T - CI and T +
CI. For the system to be profitable at our specified confidence level, we want the average
trade, T, to be greater than zero at the lower bound, T - CI; i.e.,
T > CI.
If this condition is true at the specified confidence level, it means that the system or method is
inherently profitable subject to the assumptions of the test. One of these assumptions is that
the statistical properties of the trades remain the same. Specifically, if the average trade and its
standard deviation remain the same in the future, the results will continue to be valid.
However, as markets change and evolve over time, the properties of the statistical distribution
of trades may change as well, so caution is warranted in interpreting the results.
Note: The significance test performed in MSA assumes the strategy in question is from a
single evaluation. If the strategy was arrived at by evaluating multiple candidates, such as
optimizing the strategy inputs and selecting the best result, then a different, stricter test would
be required.
MSA performs the statistical significance (t) test automatically whenever the current sequence
of trades is analyzed. The test is performed for both market-system and portfolio documents.
The number of rules and/or restrictions imposed by the trading system or method and the
confidence limit for the average trade calculation are entered on the Setup window (Analysis
menu, Options tab, for market systems or Portfolio menu, Settings tab, for portfolios). The
results of the significance test are displayed in the Significance Test tab of the Performance
Results window (View menu). The results include the average trade at the specified
confidence level (average trade +/- confidence intervals), the worst-case trade at the specified
confidence, and the probability that the average trade is greater than zero. See Chapter 12,
Viewing the Results, Significance Test Results for a detailed description of the test results.
Chapter 11
Correlation Analysis
where x and y represent arrays of equity values for the two market systems for which the
coefficient is calculated, and x and y are the averages of x and y, respectively.
To evaluate this equation, MSA uses the equity curve for each market system as it contributes
to the portfolio equity curve displayed in the chart window. The equity curves for the
individual market systems can be directly viewed in the portfolio chart window using the
Equity Curve Selection command of the View menu.
The equity array for each market system consists of a fixed number of points, equally
distributed along the date axis of each market system. The array is restricted to dates that are
common to each market system in the pair; i.e., only points for which the curves overlap are
used in the calculation. The equity values in the array are interpolated from the nearest values
on the curve.
The correlation coefficient lies in the range -1 to +1. Values less than zero indicate negative
correlation, which means that when the equity curve from one market system is increasing, the
equity curve from the other market system tends to be decreasing. Similarly, positive
correlation (correlation coefficients greater than zero) indicate that the two equity curves
move more or less together. A correlation coefficient of zero implies the two market systems
are uncorrelated.
The closer the coefficient is to -1 or +1, the stronger the correlation. A market system with
strong negative correlation to another market system is particularly valuable, especially if the
market system is profitable overall. This means that when one system is losing money, the
other one is making money, which can offset the losses from the other system. This results in
a smoother equity curve and therefore better risk-adjusted returns.
In fact, even a market system that loses money can improve the overall results of a portfolio if
it has a strong negative correlation to another market system in the portfolio. This is because
when the two equity curves are combined in the portfolio, the overall risk of the portfolio will
be reduced as profits from one market system offset losses from the other. With less risk, the
position size can be increased, which leads to greater returns.
The results of the correlation analysis are displayed in a correlation table, which is included in
the Performance Results window; see Chapter 12, Viewing the Results. The correlation table
displays the correlation coefficient for each pair of market systems in the portfolio.
71
The correlation table can be used to assess the mix of market systems in a portfolio. Ideally,
one would want negative correlation coefficients between all market-system pairs. The market
systems in such a portfolio would tend to offset each other’s losses, which would produce the
best risk-adjusted returns. By contrast, if two market systems are highly correlated (positive
correlation coefficient close to 1), their profits and losses will tend to coincide, which means
there’s little benefit in including both market systems in the same portfolio.
Note that the correlation analysis requires that the market systems comprising the portfolio
have exit dates for all trades. If the program is unable to compute the correlation coefficient,
the symbol “NA” will appear in the table in place of the coefficient values.
Chapter 12
Viewing the Results
Equity Table
The Equity Table lists the trade-by-trade results of the equity curve simulation, as depicted in
the chart window. Specifically, the Equity Table lists the symbol, trade type (regular, cost/fee,
or add/withdrawal), entry and exit dates of each trade, the profit/loss on a per
share/contract/unit basis, the risk of the trade, if any, the position sizing parameter value, the
position size (shares, contracts or units), trading costs (commission and fees), the profit/loss
for the position (trade profit/loss per share/contract/unit times the number of
shares/contracts/units less any commission and slippage costs), required margin, drawdown
(amount and percentage), and the current account equity. For a portfolio, the Equity Table
also includes a column for the market-system number (“Mark-Sys”).
The Equity Table can be sorted by any column by clicking once on the column heading. Click
again on the heading to reverse the sorting order.
If desired, the equity table contents can be exported to a text file using the Save to File
command of the File menu located on the menu bar of the Equity Table window. The table
can also be copied to the clipboard using the Copy command of the Edit menu or printed
using the File menu Print command.
To view the Equity Table, select Equity Table from the View menu. Unlike most other
windows in MSA, the Equity Table can be kept on the screen while you work elsewhere in the
program. Any changes to the data or analysis settings will be reflected in the Equity Table
while it's open, just as they are in the chart window.
Performance Results
The Performance Results window displays all performance results for the current sequence of
trades, as displayed in the chart window. Tabs along the top of the window are used to
organize the results by category. The Performance Results window for a portfolio document is
shown below. This window differs from the Performance Results window for a market-system
document only in that the portfolio window includes a tab for the correlation table, which is
not applicable to individual market systems.
73
To view the Performance Results window, select the Performance Results command from
the View menu or double-click or right-click in the right-hand pane of the main window. The
results are grouped into the following tabs:
Settings Tab
The Settings tab lists the basic settings on which the analysis is based. For market-system
documents, these settings consist of the account settings, data input settings, and position
sizing settings and rules. For portfolios, the settings include the portfolio starting account
equity, the list of market systems comprising the portfolio, and the position sizing settings and
rules currently in effect.
The following settings are listed for market-system documents:
Initial Account Equity: The starting account size in currency units (e.g., dollars) entered in
Setup.
Trading Vehicle: Either Futures or Stocks, as selected in Setup.
Slippage: The amount to deduct from each trade to account for the difference between the
ordered price and the actual fill price. Entered in Setup.
Commissions and fees: The amount to deduct from each trade to account for trading costs.
Entered in Setup.
Profit/loss calculation: Either “Profit/loss and risk calculated from P/L and risk inputs” or
“Profit/loss and risk calculated from price data input” depending on the selection on the Input
Data tab of the Analysis Setup window.
74
Summary Tab
This tab lists the performance statistics generated over the entire trading period, as reflected in
the chart window. The results are listed for all trades, for long trades only, and for short trades
only. The following performance statistics are listed under this tab:
Gross Profit: The sum of the winning trades.
Gross Loss: The sum of the losing trades.
Total Net Profit: Gross profit plus gross loss (where gross loss is a negative number).
Profit Factor: Gross profit divided by the absolute value of gross loss. Profit factors of 1.5 or
more suggest a strong system. A trading system or method with a low profit factor could
become unprofitable with just a slight change in market dynamics.
Pessimistic Return Ratio: Similar to profit factor, but discounted by the number of trades. As
the number of trades approaches infinity, the pessimistic return ratio approaches the profit
factor. See Vince, Ralph. "Portfolio Management Formulas," John Wiley & Sons, New York,
1990, p. 46.
Trading Period: The time period over which trading occurred, spanning the first trade
displayed in the equity curve to the last trade shown.
Highest Closed Trade Equity: The greatest value of account equity on a closed trade basis
over all trades in the current sequence.
Lowest Closed Trade Equity: The lowest value of account equity on a closed trade basis
over all trades in the current sequence.
Additions to Equity: Total value of all additions to account equity during the trading period.
Withdrawals from Equity: Total value of withdrawals from account equity during the
trading period.
Final Account Equity: Value of account equity on the last trade, as shown on the equity
curve in the chart window.
75
Return on Starting Equity: Percentage change in account equity from the first to last trade
relative to the initial account equity.
Number of Trades: Total number of trades, excluding those with zero numbers of
shares/contracts.
Number of Winning Trades: Total number of trades with a profit/loss greater than zero.
Number of Losing Trades: Total number of trades with a profit/loss less than or equal to
zero.
Percent Profitable: The winning trades expressed as a percentage of the total number of
trades.
Max Number of Shares/Contracts: Largest number of shares/contracts for any one trade.
Minimum Number of Shares/Contracts: Smallest number of shares/contracts of any trade,
excluding trades with zero shares/contracts.
Average Number of Shares/Contracts: Average number of shares/contracts per trade,
excluding trades with zero shares/contracts.
Largest Winning Trade: Largest winning trade, where the winners are expressed in currency
units. On the next line, the value of this trade expressed as a percentage of account equity at
the time the trade was taken is shown.
Largest Winning Trade (%): Largest winning trade, where each winner is expressed as a
percentage of account equity at the time the trade was taken. On the next line, the value of this
trade in currency units is shown.
Average Winning Trade: Average of the winning trades, where the winners are expressed in
currency units.
Average Winning Trade (%): Average of the winning trades, where each winner is
expressed as a percentage of account equity at the time the trade was taken.
Average R-Multiples, Wins: The R-multiple is the trade profit/loss divided by the risk of the
trade, including trading costs. See Tharp, Van K. “Trade Your Way to Financial Freedom,”
2nd ed., McGraw-Hill, New York, 2007. This metric is the average of the R-multiples for
winning trades.
Average Length of Wins: Average duration of winning trades in days, hours, minutes,
seconds.
Max Number Consecutive Wins: Largest number of winning trades in a row.
Largest Losing Trade: Largest losing trade, where the losses are expressed in currency units
(e.g. dollars). On the next line, the value of this trade expressed as a percentage of account
equity at the time the trade was taken is shown.
Largest Losing Trade (%): Largest losing trade, where each loss is expressed as a
percentage of account equity at the time the trade was taken. On the next line, the value of this
trade in currency units is shown.
Average Losing Trade: Average of the losing trades, where the losses are expressed in
currency units.
Average Losing Trade (%): Average of the losing trades, where each loss is expressed as a
percentage of account equity at the time the trade was taken.
Average R-Multiples, Losses: The R-multiple is the trade profit/loss divided by the risk of
the trade, including trading costs. See Tharp, Van K. “Trade Your Way to Financial
76
Freedom,” 2nd ed., McGraw-Hill, New York, 2007. This metric is the average of the R-
multiples for losing trades.
Average Length of Losses: Average duration of losing trades in days, hours, minutes,
seconds.
Max Number Consecutive Losses: Largest number of losing trades in a row.
Average Trade (Expectation): Average of all trades, where the trades are expressed in
currency units. This is also known as the expectation.
Average Trade (%): Average of all trades, where each trade is expressed as a percentage of
account equity at the time the trade was taken.
Trade Standard Deviation: Standard deviation of the trades, where the trades are expressed
in currency units. The standard deviation is a measure of variability or dispersion. 68% of
normally distributed values are within one standard deviation of the average. 99.7% are within
three standard deviations of the average.
Trade Standard Deviation (%): Standard deviation of the trades, where each trade is
expressed as a percentage of account equity at the time the trade was taken.
Win/Loss Ratio: Ratio of average winning trade to average losing trade, where the trades are
expressed in currency units.
Win/Loss Ratio (%/%): Ratio of average winning trade to average losing trade, where each
trade is expressed as a percentage of account equity at the time the trade was taken.
Return/Drawdown Ratio: Return on starting equity divided by the maximum percentage
peak-to-valley closed trade drawdown.
Modified Sharpe Ratio: Average of all trades, where each trade is expressed as a percentage
of account equity, divided by the standard deviation of the trades in percent. The modified
Sharpe ratio is a measure of risk adjusted return. Higher Sharpe ratios are better.
Sharpe Ratio: Average monthly return minus the risk-free interest rate, all divided by the
standard deviation of the monthly returns. The risk-free interest rate is the monthly rate of
interest, as entered on the Options tab of the Setup window (Settings tab of the Portfolio Setup
window for portfolios). This is a classic measure of risk-adjusted return. Higher values are
better.
Average risk: Average of position risks for all trades. The position risk is the risk per
contract/share multiplied by the number of contracts/shares for the position. The average risk
includes trading costs for the position.
Average Risk (%): Average position risk where the risk of each position is expressed as a
percentage of account equity at the time the trade is taken.
Average R-Multiple (Expectancy): The R-multiple is the trade profit/loss divided by the risk
of the trade, including trading costs. See Tharp, Van K. “Trade Your Way to Financial
Freedom,” 2nd ed., McGraw-Hill, New York, 2007. This metric is the average of the R-
multiples for all trades, both wins and losses. Tharp refers to this as the expectancy.
R-Mulitple Standard Deviation: Standard deviation of R-multiples over all trades, both wins
and losses.
Average Margin: Average value of total margin required at each trade. This might include
margin from multiple trades if two or more trades are open at the same time.
Average Margin (%): Average of margin values, where each value is expressed as a
percentage of the account equity at the time the trade was taken.
77
Max Margin (%)/Margin Value: Maximum value of margin requirement, where the margin
is expressed as a percentage of the account equity at the time the trade was taken. The margin
value in currency units (e.g., dollars) corresponding to the maximum percentage values is also
listed.
Date of Max Margin: Date at which max margin (%) value occurs.
Average Leverage: Average value of leverage over all positions. Leverage is defined as the
position value divided by the account equity.
Risk of Ruin: Probability of account depletion. See Vince, Ralph. "Portfolio Management
Formulas," John Wiley & Sons, New York, 1990, p. 136, equation R3. The equation for risk
of ruin assumes (1) unequal wins and losses, (2) a fixed number of contracts/shares per trade,
and (3) ruin is defined as 100% account depletion.
Average Annual Profit/loss: Average of all yearly profits (losses), including partial years.
Ave Annual Compounded Return: Average annual rate of return assuming annual
compounding.
Average Monthly Profit/loss: Average of all monthly profits (losses), including partial
months.
Ave Monthly Compounded Return: Average monthly rate of return assuming monthly
compounding.
Average Weekly Profit/loss: Average of all weekly profits (losses), including partial weeks.
Ave Weekly Compounded Return: Average weekly rate of return assuming weekly
compounding.
Average Daily Profit/loss: Average of all daily profits (losses).
Ave Daily Compounded Return: Average daily rate of return assuming daily compounding.
In Market System Analyzer, drawdown is defined as a decline from the highest prior peak in
closed trade equity. The drawdown is measured from the highest prior peak to the lowest
closed trade equity value.
Number of Closed Trade Drawdowns: This is the total number of drawdowns over the
current sequence of trades, as shown in the chart window.
Average Drawdown: Average value of the drawdowns expressed in currency units (e.g.,
dollars).
Average Drawdown (%): Average value of the drawdowns expressed as percentage declines
from the prior highest peak in equity.
Average Length of Drawdowns: Average duration of drawdowns.
Average Trades in Drawdowns: Average number of trades from the start of a drawdown
until the first trade that makes a new equity high.
Worst-case Drawdown: Largest drawdown, where the drawdowns are expressed in currency
units. On the next line, the value of this drawdown expressed as a percentage decline from the
prior peak in equity is shown.
Date at Trough: The date of the trade at the lowest equity point during the worst-case
drawdown.
Trade Number at Trough: The number of the trade at the lowest equity point during the
Worst-case drawdown. The trade number corresponds to that shown on the equity curve.
78
Length of Drawdown: Duration of worst-case drawdown, from the start of the drawdown to
the trade that makes a new equity high.
Trades in Drawdown: The number of trades from the start of the worst-case drawdown until
the trade the makes a new equity high.
Worst-case Drawdown (%): Largest value of the drawdowns expressed as percentage
declines from the prior highest peak in equity. On the next line, the value of this drawdown in
currency units is shown.
Date at Trough: The date of the trade at the lowest equity point during the worst-case
percentage drawdown.
Trade Number at Trough: The number of the trade at the lowest equity point during the
Worst-case % drawdown. The trade number corresponds to that shown on the equity curve.
Length of Drawdown: Duration of worst-case percentage drawdown, from the start of the
drawdown to the trade that makes a new equity high.
Trades in Drawdown: The number of trades from the start of the worst-case percentage
drawdown until the trade that makes a new equity high.
Longest Drawdown: Duration of longest drawdown, from the first trade in the drawdown to
the trade that makes a new equity high.
Start of Drawdown: Date of trade that marks the start of the longest drawdown.
End of Drawdown: Date of trade that marks the end of the longest drawdown.
Percent of Equity: Depth of longest drawdown, expressed as a percentage decline from the
prior equity peak.
Dependency Tab
The results from the dependency analysis, as determined from a statistical runs test (see
Chapter 9, Trade Dependency), are displayed in this tab. The top section of this tab displays
the results of the runs test applied to all trades in the current sequence. The dependency
identified from the runs test is listed as either Positive or Negative. Positive dependency
means that wins tend to follow wins and losses tend to follow losses. Negative dependency
means that wins tend to follow losses and losses tend to follow wins. The confidence level for
the stated dependency is listed as a percentage. The higher the number, the more significant
the dependency. A confidence level of 95% or greater may be considered significant.
The total number of runs is listed next. This is the sum of the number of runs of wins and the
number of runs of losses. A run is simply a consecutive series of trades, including series of
one trade. The average length of the winning and losing runs is also listed in this section.
The bottom section lists the results for the sliding window runs test, if selected in the Options
tab of the Setup command in the Analysis Menu (Settings tab of the Setup command for
79
portfolios). The sliding window runs test repeats the runs test over each sliding window. For
each window, the following results are listed: window number, trades comprising the window,
dependency (Positive/Negative), and confidence level (%).
The dependency results can be used as a guide in setting the dependency rules, as explained in
Chapter 9, Trade Dependency, Setting Dependency Rules.
The window lists the number of trades and the number of degrees of freedom for the current
sequence of trades. Below that, the average trade is listed with confidence intervals calculated
at the confidence level selected by the user. For example, if the average trade is $300 and the
confidence interval at 95% confidence is +/- $250, then the average trade should lie between
$50 (300 -25) and $550 (300 + 250) with 95% confidence. The average trade in this case will
be shown as $300 +/- 250. The worst-case average trade at the specified confidence level is
then shown. This is the average trade minus the confidence level. In this example, the worst-
case average trade at 95% confidence would be $50; i.e., the average trade of $300 minus the
confidence interval value of $250.
The probability that the average trade is greater than zero is also calculated and displayed in
the tab. Provided the trade distribution stays the same in the future, this is the probability that
the system or trading method will be profitable in the future. Finally, if the worst-case average
trade at the specified confidence level is less than zero, the following message is displayed:
"System/method may not be profitable at specified confidence level." Given the confidence
level and trade distribution, this indicates that there are too few degrees of freedom (too few
trades or too many restrictions) to be confident in the results. On the other hand, if the worst-
case average trade at the specified confidence level is greater than zero, the following message
is displayed: "Trades pass statistical significance test at specified confidence level." In this
case, provided the trade distribution stays the same in the future, the probability that the
system or trading method will be profitable in the future is at least as great as the specified
confidence level.
The Performance Results window can be kept on the screen while you work elsewhere in the
program. Any changes to the data or analysis settings will be reflected in the Performance
Results window while it's open, just as they are in the chart window.
The contents of the Performance Results window can be exported to a text file using the Save
to File command of the File menu located on the Performance Results menu bar. The results
can also be copied to the clipboard using the Copy command of the Edit menu or printed
80
using the File menu Print command. When saving, copying, or printing, the entire
performance report is sent, including all tabs.
If the trade data or analysis settings have been changed since the last Monte Carlo analysis
was performed, this item will be dimmed in the View menu, and the Monte Carlo analysis
must be performed again to view the results. The Monte Carlo Results window is divided into
three sections:
Trading Parameters
The Trading Parameters section contains all the analysis settings for the current sequence of
trades, as described above for the Settings section of the Performance Results window. This
section also lists the number of Monte Carlo samples used in the analysis.
Average Trade: Value of the average trade such that X% of the Monte Carlo samples had an
average trade of at least this much.
Average Trade (%): Value of the average trade, where each trade is expressed as a
percentage of trading equity at the time the trade was taken, such that X% of the Monte Carlo
samples had an average trade of at least this much.
Trade Standard Deviation: Standard deviation of the trades, such that X% of the Monte
Carlo samples had a standard deviation less than this.
Trade Standard Deviation (%): Standard deviation of the percentage trades such that X% of
the Monte Carlo samples had a standard deviation less than this.
Win/Loss Ratio: Value of the win/loss ratio such that X% of the Monte Carlo samples had a
win/loss ratio of at least this much.
Win/Loss Ratio (%/%): Value of the win/loss ratio (%/%) such that X% of the Monte Carlo
samples had a win/loss ratio of at least this much.
Max Consecutive Wins: Maximum number of consecutive wins such that X% of the Monte
Carlo samples had at least this many consecutive wins.
Max Consecutive Losses: Maximum number of consecutive losses such that X% of the
Monte Carlo samples had no more than this many consecutive losses.
Worst-case Drawdown: Value of the maximum peak-to-valley closed trade drawdown in
equity such that X% of the Monte Carlo samples had a worst-case drawdown less than this in
absolute value.
Worst-case Drawdown (%): Value of the maximum peak-to-valley closed trade drawdown
expressed as a percentage decline from the prior highest peak in equity such that X% of the
Monte Carlo samples had a worst-case drawdown less than this.
Average Drawdown: Value of the average closed trade drawdown such that X% of the
Monte Carlo samples had an average drawdown less than this in absolute value.
Average Drawdown (%): Value of the average closed trade drawdown expressed as a
percentage decline from the prior highest peak in equity such that X% of the Monte Carlo
samples had an average drawdown less than this.
Return/Drawdown Ratio: Value of the return/drawdown ratio such that X% of the Monte
Carlo samples had a return/drawdown ratio of at least this much.
Modified Sharpe Ratio: Value of the modified Sharpe ratio such that X% of the Monte Carlo
samples had a modified Sharpe ratio of at least this much.
The contents of the Monte Carlo Results window can be exported to a text file using the Save
to File command of the File menu located on the menu bar of the Monte Carlo Results
window. The results can also be copied to the clipboard using the Copy command of the Edit
menu or printed using the File menu Print command.
Optimization Results
The Optimization Results window, as shown below, displays the results of the position sizing
optimization. This window can be opened after the optimization is performed via the
Optimize Position Sizing command or it can be opened directly from the View menu by
selecting the Optimization Results command. For market-system documents, MSA stores the
most recent optimization results for each position sizing method. If no optimization has been
performed for the currently selected position sizing method, this item will be dimmed in the
83
View menu. Selecting a position sizing method for which an optimization was previously
performed for the current sequence of trades will make this item available on the View menu.
For portfolios, the results of the most recent portfolio optimization are stored and can be
viewed using the Optimization Results command, regardless of whether the analysis settings
have been subsequently changed. If the settings have been changed since the last optimization,
the portfolio should be re-optimized to reflect the new settings. If no optimization has yet been
performed for the portfolio, this command will be dimmed in the View menu.
For market-system documents, the Optimization Results window consists of two sections. The
first section, entitled "Optimal Results Over All Trades," is for the optimization performed
over all trades. If this optimization has not been performed for the currently selected position
sizing method, this section will not appear. If present, this section consists of two parts,
ANALYSIS SETTINGS, and RESULTS. Under ANALYSIS SETTINGS, all analysis options
selected at the time the optimization was performed are listed, including the optimization
objective, drawdown constraint, if selected, initial account equity, whether or not the
optimization was performed using Monte Carlo analysis, and so on.
Following the ANALYSIS SETTINGS, the RESULTS section lists the following
optimization results: optimal value of the position sizing variable, optimization objective (e.g.,
rate of return, net profit, average trade, etc.) at the optimum, and the maximum closed trade
percentage peak-to-valley drawdown at the optimum. To see a complete list of performance
statistics at the optimum, select Performance Results from the View menu.
84
The second section in the Optimization Results window is entitled "Optimal Results for
Sliding Windows." If an optimization was performed using the sliding windows option for the
currently selected position sizing method, the results of that optimization will appear in this
section. If a sliding window optimization was not performed for the currently selected position
sizing method and current sequence of trades, this section will not be shown. The ANALYSIS
SETTINGS part of this section lists all analysis settings in effect at the time the optimization
was performed and all optimization choices made for the sliding window optimization.
The RESULTS section presents the optimal results for each sliding window in tabular form.
The table consists of the following columns: window number, trade range, optimal value of
the position sizing parameter, value of the optimization objective at the optimum, and the
maximum closed trade percentage peak-to-valley drawdown at the optimum. Each line in the
table corresponds to a single optimization, performed over the trades listed under the Trades
column.
The trade numbers in the Trades column refer to the order of the trades present when the
optimization was performed. If the sequence of trades was subsequently randomized using the
Randomize Trade Order command of the View menu (or the Randomize button on the
toolbar), the current sequence may consist of a different ordering of the trades than was
present at the time of optimization. However, if the trade order is changed subsequent to a
sliding window optimization, the optimal position sizing parameter values move with the
trades. For example, if the optimal fixed fraction for trade number 16 is 0.042 following the
sliding window optimization, and the trade order is randomized so that trade 16 becomes trade
61, then the optimal fixed fraction for trade 61 will be 0.042. This is done so that a Monte
Carlo analysis performed with sliding window-derived parameter values will be more
meaningful.
For portfolio documents, the Optimization Results window is as shown below. It consists of
an Analysis Settings section and an Optimization Results section. The settings section lists all
analysis options selected at the time the optimization was performed, including the
optimization objective, drawdown constraint, if selected, initial account equity, whether or not
the optimization was performed using Monte Carlo analysis, and so on.
85
The Optimization Results section displays the optimization objective (e.g., rate of return, net
profit, average trade, etc.) at the optimum and the maximum closed trade percentage peak-to-
valley drawdown at the optimum. This section also displays a table listing the optimal value of
the position sizing variable for each market system, along with the market-system number
(“MS”), the market-system description, and the position sizing method selected for the market
system at the time the optimization was performed.
The contents of the Optimization Results window can be exported to a text file using the Save
to File command of the File menu located on the menu bar of the results window. The results
can also be copied to the clipboard using the Copy command of the Edit menu or printed
using the File menu Print command.
Chapter 13
Working with MSA Files
Overview
Market System Analyzer (MSA) creates and reads files with the extensions .msa and .msaport.
(MSA can also read older portfolio files with the extension .msp, although it’s recommended
that these older portfolio files be saved with the new .msaport extension to avoid conflicts
with Windows installer files that also share the .msp extension.) Files of type .msa store the
settings for a single market system. Files of type .msaport store the settings for a portfolio.
Because portfolios in MSA consist of multiple market systems, .msaport files also contain the
file names of the .msa files comprising the portfolio. The trade data for a market system is
stored in a separate trades file, which can be any text file with a format that MSA can read.
The name of the trades file, as shown in the Data Source command (Trades menu), is stored
in the .msa file.
The commands for working with MSA files are the New, Open, Close, Save, and Save As
commands, which are found on the File menu. Although text files of trades can be read into
MSA (provided their contents are in the proper format) using the Open command, the other
File menu commands only apply to files of type .msa and .msaport. When a .msa or .msaport
file is opened or saved in MSA, the name of the file will be displayed in the title bar of the
document window. The .msa and .msaport files are in binary format and can only be read by
the MSA program.
When a market-system document is saved and the trades file has not been specified under
Data Source, MSA will prompt you to enter a name for the trades file. In this case, MSA
creates a default name of the form MSATrades_mmddyyhhmmss_rnd.csv, where mmddyy
represents the month, day and year, hhmmss represents the current hours, minutes and
seconds, and rnd is a three-digit random number. You can either accept this default name or
enter a different name.
Previously created .msa and .msaport files can be opened outside of MSA by double-clicking
on the file name or within MSA by using the Open command of the File menu. Multiple files
of either type can be opened simultaneously in MSA. The File menu lists the 10 most recently
opened files. To open a file on this list, simply select it from the list.
Current versions of MSA can read prior versions’ files, such as version 1 or version 2 .msa
files. However, once the document is saved from within the current version, the file will no
longer be readable by the older version of MSA that originally created it. For example, if you
save a version 2 .msa file within version 3, it will become a version 3 file, and version 2 will
no longer be able to read it.
window. The results can be saved to any of the following formats: tab-delimited text (.txt),
comma-delimited text (.csv), unformatted Word (.doc), or html (.htm).
In addition, you can choose to save all current analysis results to a single file by selecting
Export Analysis Report from the File menu. This command combines the separate analysis
reports with headings for each section. The same file type options are offered as with the
separate reports (.txt, .csv, .doc, or .htm).
Chapter 14
Menu Commands
New Command
Use this command to create a new document in MSA. The new command consists of two sub-
menu items:
Open Command
Use this command to open an existing market-system (.msa) or portfolio (.msaport/.msp)
document or to select one or more text files of trade data. If text files are selected, a .msa file
will be created automatically for each file of trade data or, optionally, all trade data will be
read into a single .msa file. Also, if multiple .msa files are created from multiple text files, an
optional portfolio (.msaport) file can be created automatically from the newly created .msa
files.
Files of Type
Specifies the type of file you want to open. MSA creates files of type .msa and .msaport. You
can also select "Trade Files (*.txt, *.csv, *.xml)" or "All Files (*.*)" in this box. Select "Trade
Files" to open a text file of trade data and create a corresponding .msa file.
Close Command
Use this command to close the active document. When you close a document, MSA prompts you to
save the document if it has any unsaved changes, then closes the document window.
Save Command
Use this command to save the active document to its current name and directory. When you
save a document for the first time, MSA displays the Save As window so you can name your
document. If you want to change the name and directory of an existing document before you
save it, choose the Save As command.
Save As Command
Use this command to save and name the active document. MSA displays the Save As window
so you can name your document.
To save a document with its existing name and directory, use the Save command.
Print Command
Use this command to print the main window. This command presents a Print window, where
you may specify the range of pages to be printed, the number of copies, the destination
printer, and other printer setup options.
Print window
The following options allow you to specify how the document should be printed:
Printer
Specifies the active printer and printer connection. Choose the Setup option to change the
printer and printer connection.
Print Range
Specify the pages you want to print:
All Prints the entire document.
Selection Prints the currently selected text.
Pages Prints the range of pages you specify in the From and To fields.
90
Copies
Specifies the number of copies you want to print for the above page range.
Collate
Prints copies in page number order, instead of separated multiple copies of each page.
Paper Source
Specifies the tray for the paper source, because some printers offer multiple trays for different
paper sources.
Properties
Displays a window where you can make additional choices about printing, specific to the type
of printer you have selected.
Network
Click this button to connect to a network location, assigning it a new drive letter.
Properties Command
Use this command to display properties for the currently selected document. Displayed
properties include the file name, the full path, type of file (market system or portfolio), MSA
file version number, file size, date created, and date last modified. For market system files, the
name and path of the trades file is also shown.
1, 2, 3, …Command
Use the numbers and filenames listed at the bottom of the File menu to open the last ten
documents you closed. Select the number that corresponds to the document you want to open.
Exit Command
Use this command to end your MSA session. MSA prompts you to save any open document
that has unsaved changes.
clicking and dragging the title bar. To reduce the size of the window, click and drag the lower
right-hand corner of the window. The window can be closed at any time by clicking the close
button in the upper right-hand corner or by selecting this command. Once closed, it can be
reopened by selecting this command again or by pressing Alt+E. See Chapter 12, Viewing the
Results, Equity Table, for more information.
The Restore Original Order command restores the sequence of trades to its original order.
This command may also be accessed by right-clicking anywhere within the main window or
by using the Randomize button on the toolbar of the main chart window.
This command may also be accessed by right-clicking anywhere within the main window or
by using the Restore button on the toolbar of the main chart window.
Zoom In Command
Use this command to magnify part of the chart window. When the command is selected, the
cursor changes to a magnifying glass. Click the mouse at one corner of the rectangular area to
93
be magnified and drag the cursor while keeping the mouse button down. As the zoom cursor
is dragged across the chart window, a rectangle indicates the area that will be magnified.
Release the mouse to complete the process. The process can be repeated to zoom in further.
Select the Zoom Out command to restore the original magnification.
The Zoom In command is also available on the toolbar and in the context menu that can be
accessed by right-clicking over the chart.
The Zoom Out command is also available on the toolbar and in the context menu that can be
accessed by right-clicking over the chart.
The figures below show the two tabs of the Format Chart window.
On the Fonts and Options tab, the Title section is used to enter the chart title, which appears
above the main chart window. The font used for the title is shown in the font face and size
currently selected. Click the “Font…” button to change the font face and/or text size. All other
text on the chart is displayed using the font shown in the Labels section. Click the
corresponding “Font…” button to change the font face and size for the label text.
94
The Options section provides options for showing or hiding the data point markers, the chart
grid, the ideal equity curve, and the moving average of the equity curve. There is also an
option for drawing the equity curve as an area curve. If this option is chosen, the color
currently selected for the equity curve line is used to fill in the area below the equity curve.
The number of trades comprising the moving average of the equity curve can be entered on
this page as well.
The ideal equity curve is constructed as follows: for position sizing methods other than fixed
size, each “ideal” trade is assigned the average percentage trade. For example, if the average
trade is 0.5%, the ideal equity curve is constructed by incrementing the equity by 0.5% from
trade to trade starting with the starting account equity value. On a linear chart, this produces
an equity graph that curves upward (i.e., has increasing slope). On a logarithmic scale, this
curve is a straight line because the rates of return for all periods (trades in this case) are the
same. If the slope of the actual equity curve is close to that of the ideal equity curve when
plotted on a logarithmic scale, it indicates that the trading system or method has uniform
performance over different time periods.
For fixed size position sizing, the ideal equity curve is constructed by assigning each “ideal”
trade the average trade in currency units (e.g., dollars). In this case, the equity curve is
generated by incrementing the equity by the average trade amount from trade to trade,
resulting in a straight-line equity curve on a linear chart. On a logarithmic chart, the ideal
equity curve in this case will curve downward (i.e., has decreasing slope).
The Lines and Colors tab allows you to set the line color and line width of the equity curve,
trade size bar graph (color only), moving average, ideal equity curve, and tick marks at new
equity highs.The color is chosen from a drop-down list of standard colors. To choose a color
not on the list, select the last item in the drop-down list, “other…” This will bring up the color
picker screen, which will enable you to choose any color available on your system.
Alternatively, you can select one of the pre-defined color schemes from the Color Scheme
pull-down menu at the top of the page. This will set colors for each component. Line widths
are unaffected by the color scheme choice.
Line widths are also chosen from a drop-down list, which provides widths from 1 to 20 pixels.
Click OK to apply the chosen selections.
95
The Format Chart command may also be accessed by right-clicking anywhere within the main
window.
Toolbar Command
Use this command to display and hide the toolbar, which includes buttons for some of the
most common commands in MSA, such as File Open. A checkmark appears next to the menu
item when the Toolbar is displayed.
Toolbar
The toolbar is displayed across the top of the application window, below the menu bar. The
toolbar provides quick mouse access to File menu functions (New, Open, Save, Print), as
well as common analysis functions, such as Setup, Position Size, Optimize, Randomize, etc.
Place the mouse cursor over a button (without clicking) to display a brief description of the
96
button. The small, downward-pointing button at the right edge of the toolbar provides options
for adding or removing toolbar buttons and for opening the Customize menu (see below).
To hide or display the toolbar, click Toolbar from the View menu.
Select a performance statistic in the summary pane to see a description of it in the area below
the pane. To view the complete performance report, right-click anywhere in the summary
pane and select “View Full Results”. The summary pane results can be copied to the clipboard
by right-clicking and selecting “Copy”.
See Status Bar below for help on using the status bar.
Status Bar
The status bar is displayed at the bottom of the MSA main window. To display or hide the
status bar, click Status Bar from the View menu.
The left area of the status bar describes actions of menu items as you use the arrow keys to
navigate through menus. This area similarly shows messages that describe the actions of
toolbar buttons as you select them, before releasing them. If after viewing the description of
the toolbar button command you decide not to execute the command, then release the mouse
button while the pointer is off the toolbar button. When the left mouse button is clicked over
the equity curve, the left area of the status bar displays the following information for the trade
at the cursor location: trade number, market-system number (portfolios only), date/time,
equity value, drawdown (% drawdown), and position size.
The right areas of the status bar indicate which of the following keys are latched down:
Indicator Description
CAP The Caps Lock key is latched down.
NUM The Num Lock key is latched down.
SCRL The Scroll Lock key is latched down.
Customize Command
Use this command to customize the menus, toolbars, and keyboard shortcuts. The right-click
context menus for the main chart window can be customized using the Menu tab. On the
right-hand side of the menu tab, select the context menu under “Context Menus”. Then switch
to the Commands tab, select a command from the list, and drag and drop it onto the context
menu. To remove a command from the context menu, drag it off the menu.
97
Edit/Add Command
Use this command to edit, add, and delete trades. This command opens the Edit/Add Trades
window, which lists the trades in their original order. When restricting the current sequence of
trades to a subset of the original sequence using the toolbar, use the trade numbers listed in the
Edit/Add Trades window. See Editing Input Data in Chapter 3 for details on using the
Edit/Add Trades window.
of data in the file, including the columns to read and the ones to ignore. The Trades File
Format window is not displayed (and is not necessary) when reading trade data from RINA
xml files.
Two pre-set formats, available on the Preset column format pull-down menu of the Trades
File Format window, are designed to simplify this process. The first predefined format is the
TradeStation Trades List. Select this format to import trade data from a text file generated
from the Trades List portion of a TradeStation performance report. The file should be in text
format, either as a .txt or .csv file. TradeStation software, version 8 or newer, is required. To
create the file, view the TradeStation performance report from within TradeStation. Save the
report as an Excel (.xls) file, then open the saved file in Excel. Go to the Trades List sheet and
“save as” the spreadsheet as a .txt or .csv text file. Only the Trades List sheet will be saved.
Also see Chapter 3, Input Data, Getting Data into the Program.
The other predefined format is the WriteTrades3 file format. Use this format to import trades
from a text file generated by the WriteTrades TradeStation function, which is included with
MSA. The WriteTrades function is designed to be called as the last line in a TradeStation
strategy. It generates a text file that contains the trade data needed by MSA. See Chapter 3,
Input Data, WriteTrades EasyLanguage Function.
Export Command
Use this command to export the trade data currently in MSA to a file. This command opens
the Export Trades window, which allows you to choose an existing file or name a new file to
contain the exported trades. For each trade, the following data are written: symbol, entry date,
entry price, exit date, exit price, stop price, trade direction (1/-1), profit/loss, risk, trade size,
ATR, currency conversion factor, and trade type (0 – 2). The trades can be saved to any of the
following formats: tab-delimited text (.txt), comma-delimited text (.csv), unformatted Word
(.doc), or html (.htm). To import a .csv or .txt file created with the Export command, select the
WriteTrades3 preset format on the Trades File Format window and use the option to skip the
first two lines. Also see Chapter 3, Input Data.
will be recalculated, and the equity curve will be redrawn. To instruct MSA to execute this
command automatically at specified intervals, use the Setup command of the Analysis menu.
Setup Command
Use this command to enter analysis settings and options. The Analysis Setup window has
three tabs: Input Data, Account Settings, and Options. See Chapter 4, Basic Settings, for a
detailed description of each tab. Briefly, the Input Data tab allows you to control how the
input data are interpreted. Settings include the trading vehicle (stocks or futures), the point
value (futures only), whether the profit/loss and risk amounts are determined from price inputs
or from the P/L and risk amounts themselves, the default trade size, and several options
specifying whether trading costs are included in the data. There is also an option on this tab to
reload the file of trade data at specified intervals.
The Account Settings tab allows you to set basic options related to your trading account, such
as the starting account equity value, margin requirements, and trading costs. You can also
select the locale for your trading account on this tab. The locale determines the currency unit
used for display purposes (dollar, Yen, Euro, etc.) as well as the number format. There is also
an option on this tab to set up a schedule of regular account withdrawals within the
simulation. If you plan to regularly withdraw money from your trading account, this option
will make the simulation more accurate.
The Options tab contains a number of options for position sizing, Monte Carlo analysis,
dependency analysis and the significance test. The position sizing options include the ability
to specify a minimum position size, the option to trade a fixed size until the account equity
reaches a specified threshold, and the option of trading in multiples of a fixed size, such as
100 shares. The full set of options is discussed in Chapter 4.
The drop-down Source menu in the Parameters section is used to tell Market System Analyzer
where to obtain the position sizing parameter values. There are four choices: “User Entries
(below),” “Optimization, All Trades,” “Sliding Window Opt, In-sample,” and “Sliding
Window Opt, Out-of-sample.”
If the first option is chosen, the parameter values for position sizing are obtained from the
values entered by the user on the Position Sizing Method tab for the currently selected
position sizing method. If the second option is selected, MSA uses the optimal value of the
position sizing parameter for the currently selected method, as determined from the
optimization over all trades. If the optimization has not been performed for the currently
selected position sizing method, the values entered by the user will be used instead.
If the third or fourth option is chosen, the position sizing parameter values obtained from
optimizing over a sliding window of trades will be used. If the sliding window optimization
has not been performed for the currently selected position sizing method, the values entered
by the user will be used instead. There are two ways to use the sliding window parameter
values: in sample (as optimized), or out-of-sample (walk-forward). Selecting the third option
from the drop-down list ("…in-sample") means that the parameter values will be applied to
the same trades that were used in the optimization. For example, suppose the optimization
window was 30 trades in length, and the optimized parameter was the delta (fixed ratio
method). The optimization would have used trades 1 - 30 for optimization window #1.
Applying the optimal delta in-sample means that trades 1 - 30 will use the optimal delta from
window #1. Trade 31 will use the optimal delta from window #2 (trades 2 - 31). Trade 32 will
use the optimal delta from window #3 (trades 3 - 32), and so on.
101
If the fourth option ("…out-of-sample") is selected, the optimized parameter value will be
assigned to the trade following the optimization window. In the example above, the delta
value for trade 31 will be the optimal value from window #1 (trades 1 - 30). The delta value
for trade 32 will be the optimal value from window #2 (trades 2 - 31), and so on. Trades 1 - 30
will have a position size of zero because there is no out-of-sample value to assign to trades in
the first window. Selecting this option provides a way to test the optimized parameter values
on data not used in the optimization. This is known as out-of-sample testing.
The Notes section on the bottom right of the Position Sizing Method tab provides a brief
description of the selected position sizing method.
When the OK button is clicked, the chart will be redrawn to employ the selected position
sizing method. All subsequent analyses will employ the selected method. The chosen position
sizing method will also determine the parameter optimized during position sizing
optimization; e.g., for fixed fractional position sizing, the optimized parameter will be the
fixed fraction (percent risk). See Chapter 8, Optimizing Position Sizing, Optimization
Objectives, for a list of the parameters optimized for each position sizing method.
See Chapter 5, Position Sizing, Equity Curve Crossovers, for further information.
See Chapter 9, Trade Dependency, Setting Dependency Rules, for a description of each
dependency rule.
Setup Command
Use this command to enter analysis settings and options for a portfolio. The Portfolio Setup
window has two tabs: Market Systems and Settings. See Chapter 4, Basic Settings, for a
detailed description of each tab. Briefly, on the Market Systems tab, the Add Market
System(s)... button can be used to select any number of existing market-system (.msa)
document files. The selected market systems will be added to the portfolio. A market system
can be removed using the Remove Market System(s) button. To open one of the market-
system documents comprising the portfolio, either double-click on the market-system name in
103
the list or use the Open File(s) button. The check box at the bottom of this tab can be used to
automatically reload the chart data at specified time intervals.
The Settings tab allows you to set basic options related to your trading account, such as the
starting account equity value, and options for Monte Carlo analysis, dependency analysis and
the significance test. You can also select the locale for your trading account on this tab. The
locale determines the currency unit used for display purposes (dollar, Yen, Euro, etc.) as well
as the number format.
By default, the settings are retrieved from the market-system file. To change a parameter
value, change the Parameter Source to User Selected on the Position Sizing window then
enter the new value in the space provided.
The Position Sizing Method window lists the different position sizing methods available in
MSA. See Chapter 5, Position Sizing, for a description of each method. When a method is
selected from the list, the name of the method is displayed to the right of the list in the section
marked “Method.” Below that, in the Parameters section, the method’s parameter values can
be entered, such as the percentage of equity to risk per trade in the fixed risk method.
104
The drop-down Parameter source menu in the Parameters section is used to tell MSA where to
obtain the position sizing parameter values. There are three choices: “User Selected,” “Market
System File” and “Portfolio Optimization.”
If the first option is chosen, the parameter values for position sizing are obtained from the
values entered by the user in the Parameters section for the currently selected position sizing
method. If the second option is selected, MSA retrieves the position sizing parameter value
from the market-system file. If the last option is chosen, the value of the position sizing
parameter for the currently selected method is obtained from the most recent portfolio
optimization if one has been performed.
The Notes section on the bottom right of the Position Sizing Method tab provides a brief
description of the selected position sizing method.
See Chapter 5, Position Sizing, Equity Curve Crossovers, for further information.
See Chapter 9, Trade Dependency, Setting Dependency Rules, for a description of each
dependency rule.
105
Reload Command
This command reconstructs the portfolio by reading each individual market-system file and
adding it to the portfolio. When each market-system file is read, the trades file is loaded. As a
result, the Reload command updates the portfolio with the latest trade data from each market
system. To instruct MSA to execute this command automatically at specified intervals, use the
Portfolio Setup command.
New Horizontal Tab Group Splits the chart window horizontally into
two panes
New Vertical Tab Group Splits the chart window vertically into two
panes
New Window Creates a new window that views the same
document.
Split Splits the chart window into either two or
four user-sized panes.
106
Split Command
Use this command to split the active window into additional panes, with a copy of the active
document in each pane. When this command is selected, the mouse cursor changes to
crosshairs that span the active window. Move the cursor to divide the window into four panes.
Move the cursor all the way to the bottom or top of the window to split the window vertically.
Move the cursor all the way left or right to split the window horizontally. To remove the split,
drag the split line to the edge of the window.
Help Topics Offers an index to topics on which you can get help.
About Displays information about this application.
Market System Analyzer uses closed trade equity. Won't this underestimate the true
drawdown?
In some cases, using closed trade equity for drawdown calculations will underestimate the
drawdown. This is usually only a concern for long-term system, which may have large swings
in equity during the trade. Even with these types of systems, however, only a fraction of the
trades generally experience intra-trade drawdowns that completely reverse before the trade
exits. If, on the other hand, a trade exits at its worst intra-trade drawdown, the closed trade
equity will also accurately represent the intra-trade drawdown.
If you want to use MSA for long-term trading, consider using the daily, weekly, or monthly
returns as input data in place of trades. For example, if you enter the daily changes in equity as
trade data, each day’s equity change will be considered to be a trade.
There's more to adding additional shares/contracts than position sizing. Because these
subsequent entries take place at different times and under different conditions than the original
entry, they should be viewed as comprising an additional trading system. This other "system"
may have the same exit as the original system, but it has a different entry, effectively making
it a different system. Viewed this way, position sizing in pyramiding should be applied
separately to the original entry and to the subsequent, pyramided entries. In fact, the original
entries and the pyramided entries could be analyzed as separate trading systems in a portfolio.
100 shares or $300) would be required to purchase the option. The resulting trade would be a
profit of $100 (net option profit of $1 x 100 shares). Each “unit” would represent one option.
A futures option trade would be entered in MSA the same way as a futures trade. You would
select “futures” as the trading vehicle and enter the point value for the underlying futures in
the Point Value field of the Analysis Setup window. Enter the required option margin on the
Account Settings tab of the Analysis Setup window. Futures options are generally priced for
one contract, so the trade size should be one contract.
The margin requirements for naked option writing are more difficult to represent in MSA. For
example, to write a naked equity index option might require a margin of 15% of the index
value. The total cost of the trade would be the margin amount plus the option premium minus
any out-of-the money amount. There is no easy way to account for this in MSA.
I only have a small sample of trades. Will I still get good results?
Many of the analyses in Market System Analyzer will be compromised if you start from a
small number of trades. For statistical reliability, you should have at least 30 trades. If you
have fewer trades but you believe the trades are an accurate representation of your trading
system or method, you might want to expand your list of trades using one of the methods
described in Chapter 6, Monte Carlo Analysis, Overview. The more trades available to the
program, the more accurate calculations such as the worst-case drawdown will be.
If the optimization is over a sliding window of trades and the number of trades in the window
is too small, some windows might lie within a drawdown, making it impossible for the
optimization to find a profitable result over that window. Increasing the number of trades until
109
the window exceeds the length of the drawdown should eliminate this problem. Monte Carlo
analysis for sliding window optimization is also usually a good idea.
Lastly, if you’re optimizing a single market system, try the other search method (see Chapter
8, Optimizing Position Sizing, Search Methods). Adaptive search is usually preferable except
when using fixed size position sizing. However, if adaptive search is unsuccessful, try
exhaustive search. It may take longer but may be more likely to find a solution.
When I apply the sliding window optimization results, why don't they match the results
in the optimization results window?
Even if the optimization results for every sliding window appear to be good, the resulting
equity curve when the optimal parameter values are applied may not be as good. This is due to
the cumulative effect of building the equity curve from successive sliding windows. In
particular, while the optimization may limit the drawdown to a reasonable percentage -- say,
30% -- the cumulative drawdown in adjacent windows may be greater than this. For example,
window #5 may end in a drawdown of 25%, and window #6 might start off with a drawdown
of 20%, resulting in a combined drawdown of 45%, which exceeds the optimization limit of
30%.
Similar problems can occur when the optimal parameter values are applied out-of-sample; i.e.,
walk-forward. For example, suppose the optimal fixed fraction for window #10 was 0.08
(8%). This might be the result of maximizing the rate of return subject to a drawdown
constraint of 20%, which means that the drawdown in each sliding window was limited to
20%. However, if window #11 has a less favorable sequence of trades than window #10, that
8% fixed fraction could result in a drawdown much larger than 20% when applied "forward"
in window #11.
To eliminate or at least minimize these problems, try increasing the size of the sliding
window. Using Monte Carlo analysis will also help by producing more consistent optimal
values from window to window.
If you’re optimizing a single market system, try using the alternative search method (see
Chapter 8, Optimizing Position Sizing, Search Methods).
As an alternative to position sizing optimization for single market systems, try using the
Parameter Studies feature (see Chapter 7, Parameter Studies). By plotting the rate of return
followed by the worst-case drawdown, it’s usually possible to find a good parameter value
fairly quickly.
For optimizing portfolios, the option of starting the optimization at values chosen by the
program can increase the optimization time considerably. This is because MSA evaluates the
portfolio at a series of randomly selected starting points prior to beginning the main
optimization. If you’ve entered a drawdown constraint, it may take additional time to find
random trial values that meet the constraint. In this case, to speed up the optimization, you can
either use a less restrictive drawdown constraint or start the optimization at the current
position sizing parameter values.
110
How do I add a trade to the bottom of the list of trades in the Edit/Add Trades window?
You need to deselect any trade that may be selected (highlighted). To do this, scroll to the
bottom of the list of trades and click in the space immediately below the last trade in the list. If
you then click the Add Trade button, the trade number shown on the Edit/Add Trade window
should be for the next trade in the sequence.
When I apply the moving average equity crossover rule, why don’t the crossovers on the
chart seem to match where the program adjusts the position size?
This can be a little confusing, but the program is working correctly. The equity crossover rules
change the position sizing based on crossovers of the equity curve with its moving average.
However, when you plot the moving average on the screen, the crossovers probably won't
match up exactly with the trades that have had their position sizing changed by the crossover
rule. This is because the equity curve is actually calculated twice. In the first pass, the
crossover locations are determined, but the crossover rule is not used to change the position
size. During the second pass, the crossover locations are used to apply the crossover rule and
adjust the number of shares/contracts. This is necessary because applying the crossover rule to
change the position size alters the equity curve and thereby changes the crossover locations.
The moving average that is plotted on the equity curve is the moving average of the equity
curve that you see on the chart, which includes the effect of the crossover rule. If you want to
see the moving average and the crossover points that were used to adjust the position sizing,
turn off the equity crossover rule but leave the moving average plotted on the chart.
Appendix: Position Sizing Code for
TradeStation and MultiCharts
Although Market System Analyzer (MSA) is designed as a stand-alone program, some users
will no doubt want to perform their position sizing calculations within TradeStation or
MultiCharts. To make this easier, the EasyLanguage function, PSCalc, implements the
position sizing methods of MSA. After the function is discussed, an example illustrates the
use of PSCalc in a simple trading system. The example also demonstrates how the PSCalc
function can be used to optimize trading system and position sizing parameters simultaneously
in TradeStation.
The PSCalc EasyLanguage function is designed to be called from the code of an existing
trading system. It calculates and returns the number of shares/contracts based on the account
equity and the selected position sizing method. The position sizing method and associated
parameter values are determined from the input parameters of the function.
PSCalc can be used either to back-test trading systems or in day to day trading to determine
the number of shares/contracts for the next trade. In back-testing mode, the function
accumulates the account equity after each trade and bases the position size on the accumulated
equity (or accumulated profit for fixed and generalized ratio trading). For day to day trading
purposes, the function uses the input value of the trader's current account equity to calculate
the number of shares/contracts for the next trade.
You can find the function in the files PSCalc32.eld (TS 8 or newer and MultiCharts),
PSCalc32.els (for TS 2000i) or in the text file PSCalc32.txt, which are included with licensed
(paid) version of MSA. PSCalc is not available in the trial version of MSA.
The input parameters of the function are listed below. A value should be provided for each
parameter unless it corresponds to a position sizing method that you do not plan to use. In that
case, a value of zero can be used.
Input Description
PSMeth position sizing method, as defined in the table below.
Param1 1st position sizing parameter. See table below.
Param2 2nd position sizing parameter. See table below.
BackTest true/false; true means account equity is accumulated;
false means CurEqty is used as total equity.
StEqty initial account size (starting equity) in dollars.
CurEqty current value of account equity in dollars; only used when
BackTest = false.
TrRisk risk for current trade, per share/contract/unit
MxLoss largest 1-share/contract/unit loss
MaxDD largest 1-share/contract/unit drawdown
Stocks true if vehicle is a stock; false if futures.
UseUnits true/false. If true, number of shares/contracts is a
multiple of UnitSize; e.g., 100 shares per unit.
UnitSize size of trading unit; e.g., 100 shares.
UseMinN true/false. If true, the number of shares/contracts
is always at least equal to MinN. In other words, if the number
112
The position sizing method is determined by the value of the first parameter, PSMeth. Inputs
Param1 and Param2 are the parameters for the selected position sizing method. The
correspondence between the position sizing method and Param1 and Param2 is shown in the
following table:
Except for the “Classic f” method (#6), these methods are the same as described in Chapter 5,
Position Sizing. The classic f method is the same as the fixed risk method except that the risk
of the trade is taken as the largest historical loss, as given by parameter MxLoss. The fixed
risk method (#3), by contrast, uses the value of TrRisk as the trade risk, which may be
different for each trade. If the classic f method is selected, then Param1 will be the fixed
fraction. If, for example, Param1 is set to the optimal f value, as calculated by MSA, then the
position sizing will be the optimal f method.
The fourth parameter, BackTest, is used to select between back-testing mode (BackTest =
true) and day to day trading mode (BackTest = false). If BackTest = false, the parameter
CurEqty should be set to the current value of account equity. If BackTest = true, CurEqty is
ignored. The next parameter, StEqty, is the starting account equity. If BackTest = false,
StEqty is only used for fixed and generalized ratio trading, where it's used to calculate the
total profit (total profit = CurEqty - StEqty).
TrRisk is the risk amount for the current trade on a per-share/contract/unit basis. This is used
for fixed risk and profit risk position sizing. The next parameter, MxLoss, is the largest loss
(on a 1-share/contract/unit basis) among all trades in the trade history. This is used for the
“Classic f” position sizing method, discussed above. The MaxDD parameter is the largest
peak-to-valley drawdown in the trade history on a 1-share/contract/unit basis. This is used in
the Max Drawdown method.
113
The Stocks parameter is a true/false value that is true if the trading vehicle is stocks and false
if the trading vehicle is futures. To trade in multiples of a fixed number of shares or contracts,
set the UseUnits parameter to true and set the UnitSize parameter to the fixed number of
shares or contracts. For example, with UnitSize equal to 100, the position size will be a
multiple of 100 shares. The UseMinN parameter allows you to force the position size equal to
MinN in cases where it would otherwise be less than that. MaxN is the maximum allowable
number of shares or contracts. This is provided to keep the position size from getting
unrealistically large during back testing.
The next two parameters are for setting the minimum margin requirement. InitMarg is the
initial margin requirement per contract for futures trading. For stock trading, set MargPer to
the minimum percentage margin requirement (e.g., 50%).
The last parameter, NATR, is used to set the number of bars over which the average true
range (ATR) is calculated. This is only used when the percent volatility position sizing
method is selected.
To illustrate the use of the PSCalc function, the following EasyLanguage system code is
provided. This system, called PSExample3, is a simple breakout system intended primarily
for the E-mini S&P 500 futures. The EasyLanguage code can be found in the files
PSExample3.eld, PSExample3.els, or in the text file PSExample3.txt.
The first two inputs to the system relate to the trading rules of the system. The remaining
inputs relate to the PSCalc function. The system enters at a fraction of the prior day's range
from the prior day's high. The fraction of the prior day's range is given by the first input. The
second input is the size of the money management stop in dollars. The remaining inputs are
the same as the parameters of PSCalc, except that the TrRisk parameter is a variable rather
than an input to the system. TrRisk, the dollar value of the trade risk per contract, is set to the
size of the money management stop.
{
PSExample3 strategy
This simple system is designed to illustrate the use of the PSCalc
function for position sizing.
Adaptrade Software
www.Adaptrade.com
TrRisk = StopSz;
{ Entry conditions }
NCon = PSCalc32(PSMeth, Param1, Param2, BackTest, StEqty, CurEqty, TrRisk,
MxLoss, MaxDD, Stocks, UseUnits, UnitSize, UseMinN, MinN,
MaxN, InitMarg, MargPer, NATR);
{ Exit conditions }
Sell("MMStop") next bar at EntryPrice - TrRisk/BigPointValue stop;
If BarsSinceEntry >= 1 and open of next bar > EntryPrice then
Sell("ProfOpen") next bar at market;
Placing the function parameters as inputs to the system enables you to optimize the position
sizing within TradeStation or MultiCharts using the built-in optimization feature of the
platform. You can even optimize the system and position sizing parameters simultaneously.
For example, in fixed fractional position sizing, the position size depends on the trade risk. In
this system, the trade risk is equal to the size of the money management stop. To illustrate, the
size of the money management stop, StopSz, and the risk percentage, RiskPer, were optimized
together using PSMeth = 3 (fixed fractional position sizing). BackTest was set to true for
these tests.
The symbol was @ES (E-mini S&P 500 futures, continuous contract). The period was
1/2/2003 to 8/20/2004 with a look-back length of 1 bar. The initial account size (StEqty) was
$30,000, and $75 was deducted per contract for slippage and commissions. For comparison,
the system parameters were first optimized by themselves on a fixed contract basis. Three
115
contracts were taken per trade. Based on net profit, the optimal parameter values were EntFrac
= 0.8 and StopSz = 1700. These parameters produced the following results:
Next, the stop size and the fixed risk (Param1) were optimized together with the entry
fraction, EntFrac, set at the value of 0.8 from the prior, fixed contract optimization. In this
case, a very different optimal stop size was found. With fixed risk position sizing, the best
stop size was $700 (compared to $1700 with fixed contract position sizing) using a fixed risk
percentage of 18%. The optimal results using these parameter values were:
In practice, a risk percentage of 18% is far too high (notice the drawdown of 40%). However,
even with smaller risk percentages, the optimal stop size was different than $1700 using fixed
risk trading. This illustrates that position sizing can interact with a system's trading rules, and
suggests that there may be merit in setting system parameter values and position sizing
parameter values together.
In this example, the money management stop size was optimized. However, using the PSCalc
function as illustrated here, any system input can be optimized together with any position
sizing parameter. If you go through this type of analysis with your own trading system, it's
recommended that you run the results through MSA's Monte Carlo analysis to confirm that
your chosen position sizing parameter values are reasonable. In general, to utilize the
capabilities of both MSA and TradeStation/MultiCharts when optimizing a trading system,
consider following the steps below:
As with any optimization, you should have a sufficient number of trades to avoid over-fitting
the system to the market data. You can use the significance test feature of MSA to help
determine if this is the case. In addition, out-of-sample testing is recommended after
optimization.
116
To calculate the position size for day to day trading purposes, set BackTest = false and set
CurEqty to the current value of your account equity. The position size for the next trade will
be specified in the Quantity column of the Strategy Orders tab in TradeStation 8. If using
fixed or generalized ratio trading, make sure that StEqty is also set correctly so that the total
profit (CurEqty - StEqty) will be correct. Before each new entry, make sure CurEqty is set to
the current value of your account equity.
Index
Gross Loss ........................................................... 79
account size ................................. 17, 38, 46, 49, 78 Gross Profit ......................................................... 79
adaptive search method ....................................... 66
analysis reports.................................................... 93 Highest Closed Trade Equity .............................. 80
antimartingale ..................................................... 43
Average Drawdown ...................................... 83, 88 ideal equity curve .......................... 12, 99, 100, 101
Average Losing Trade ................................... 81, 87 import .......................................................... 58, 105
Average Number of Shares/Contracts ........... 80, 87 in sample ..................................................... 66, 108
Average Number of Trades in Drawdowns ......... 83 Initial Account Equity ......................................... 78
Average Trade ......................................... 64, 81, 88 Input Data ..... 2, 3, 15, 20, 31, 34, 37, 51, 104, 105,
Average Winning Trade ................................ 80, 87 106
Commissions and Slippage ........................... 78, 79 Kelly formula .................................... 46, 47, 48, 65
confidence interval .................................. 72, 74, 84
confidence level . 57, 60, 62, 66, 68, 72, 73, 74, 84, Largest Losing Trade..................................... 81, 87
85, 86 Largest Winning Trade .................................. 80, 87
copying to the clipboard ...................................... 14 leverage ............................... 34, 37, 43, 51, 62, 122
correlation coefficient ............................. 75, 76, 85 line width ........................................................... 101
correlation table ...................................... 76, 78, 85 logarithmic chart ......................................... 13, 100
current sequence of trades ................................... 13 Logarithmic plotting ............................................ 13
Lowest Closed Trade Equity ............................... 80
Data Source ....................................................... 104
degrees of freedom ............................ 72, 73, 84, 85 main chart window13, 66, 77, 80, 83, 85, 100, 109,
dependency analysis .............. 10, 39, 42, 53, 69, 70 110, 113
dependency rules ......... 18, 43, 68, 69, 84, 109, 113 margin requirement ..... 34, 37, 50, 51, 52, 122, 123
drawdown constraint ....................... 65, 89, 90, 118 margin requirements 2, 36, 44, 47, 48, 52, 106, 117
market system ........................................................ 9
EasyLanguage .................................... i, 28, 29, 121 martingale ............................................................ 43
Edit/Add command .......................... 13, 15, 32, 98 Max Number Consecutive Losses ....................... 81
equity crossover .................. 52, 109, 112, 117, 120 Max Number Consecutive Wins ......................... 81
equity curve ......................................................... 12 Max Number of Shares/Contracts ................. 80, 87
Equity Table ................................ 16, 69, 77, 97, 98 menu bar .......................................... 85, 88, 91, 102
exhaustive search ........................................ 67, 118 Minimum Number of Shares/Contracts ......... 80, 87
Modified Sharpe Ratio ............................ 64, 81, 88
Final Account Equity .................................... 80, 87 money management stop ......................... 15, 31, 47
fixed fractional position sizing .................... 15, 109 Monte Carlo analysis.... 17, 18, 44, 57, 62, 65, 66,
fixed ratio ........................................ 49, 50, 61, 108 85, 90, 97, 98, 106, 109, 110, 113, 118
Fixed ratio .................................................... 49, 65 Monte Carlo samples ........................................... 60
Fixed risk ...................................................... 48, 65 moving average 9, 12, 52, 53, 54, 72, 99, 100, 109,
floating menus ..................................................... 14 112, 120
font .................................................................... 100 MultiCharts ....i, iv, vii, 1, 20, 25, 28, 29, 121, 124,
fonts .............................................................. 10, 99 125
forex .................................................................. 117
format ............................................................ 92, 99 negative correlation ................................. 75, 76, 85
Format Chart ................................ 54, 97, 99, 101 negative dependency ........................................... 68
futures option .................................................... 117 Number of Closed Trade Drawdowns ................. 83
number of contracts ............................................. 12
generalized ratio .................................................. 50 Number of Losing Trades.................................... 80
Generalized ratio ......................................... 50, 65 number of restrictions .......................................... 72
118