|
The 'Strategy Test' tab is used to specify the criteria, run the test, and view summary results. The other tabs will show the detailed results of the Test.
|
Introduction to Backtesting Backtesting allow you to test trading strategies across a range of historical dates. Tests can be made against specific symbols or you can use position sizing rules to simulate multi-holding portfolios. You can run and compare multiple Tests for the same Strategy to quickly see how criteria or parameter changes affect the results. A Strategy consists of trade criteria, stops, targets, and position sizing rules. For example, a Strategy may consist of the following elements: - buy when the Close Price crosses above a 10 day Moving Average
- sell when the Close Price crosses below a 5 day Moving Average
- close a position, using a stop, if it loses more than 5%
- close a position, using a target, if it gains more than 20%
- start with equity of 100,000
- buy 100 on each trade regardless of stock price or volatility
- maintain no more than 10 open positions at a time, with a maximum of 5 new positions on any one day
- when there are more buy signals than position slots available, choose stocks in descending order of 10 day Average Volume.
You could then run multiple Tests with perhaps different MA Periods and easily compare the results to see which is more profitable. Click 'Customize Criteria and Run Test' to open or close the criteria customization panel.
In the customization panel you can run tests and make copies. If you are viewing one of your existing Tests click 'Run Test' to run another test under the Strategy or 'Copy to New Strategy' to build an additional Strategy based on the test currently on display. And if the Strategy on display is a site sample or from another user click 'Apply Changes & Save to My Id' to save it to your account.
Once your Test has completed running you can view summary results in the Grid below and detailed information on the other tabs on this page. Include and Exclude Symbol Groups Symbol Groups are the universe of symbols to search. Various different methods of selection are available including Exchanges, Sectors, Watch Lists, Specific Symbols, etc.
You can also choose to Exclude specific symbols or groups of symbols. If there is a recurring group of stocks you wish to exclude it may be better to set these up in a watch list and exclude the list. Criteria Basics Buy, Sell, Short Sell, and Cover Short criteria allow you to set separate rules for entering and exiting trades. As a minimum, you must enter either at least one Buy or at least one Short Sell criteria. You do not need to enter Sell or Cover Short criteria if all trades are to be closed by stops.
The Buy and Short Sell criteria will be evaluated each day of the Test to determine new positions, subject to the available Equity, Position Sizing, and Maximum Position settings. The Sell and Cover Short criteria will be evaluated each day of the Test for existing positions to see whether they should be closed. In general, each filter criteria consists of a comparison between one fundamental or technical analysis value and another fundamental or technical analysis value, or a specific value.
You may have the following criteria:
- Close Price greater than or equal to 10
This simple criteria will return all stocks where the close price is greater than or equal to 10 dollars.
This criteria is not very selective so we could include an additional comparison as follows:
- Close Price greater than or equal to 10
- Close Price crossed above Simple Moving Average(200)
Now the criteria will return all stocks where the close price is greater than or equal to 10 dollars and the close price has crossed above the 200 day moving average. Criteria Conditions Equal to
compares the item on the left-hand side of the criteria with the item on the right-hand side. The right-hand item can be a specific value.
The criteria will pass if the left is exactly equal to the right.
Be careful with 'Equal to' and technical values as there may be rounding issues. For example, rather than having a criteria of 'Beta equal to 1', it may be better to use two criteria of 'Beta greater than or equal to .99' and 'Beta Less than or equal to 1.01'. Less than
compares the item on the left-hand side of the criteria with the item on the right-hand side. The right-hand item can be a specific value.
The criteria will pass if the left is less than the right. Less than or equal to
compares the item on the left-hand side of the criteria with the item on the right-hand side. The right-hand item can be a specific value.
The criteria will pass if the left is less than or exactly equal to the right. Greater than
compares the item on the left-hand side of the criteria with the item on the right-hand side. The right-hand item can be a specific value.
The criteria will pass if the left is greater than the right. Greater than or equal to
compares the item on the left-hand side of the criteria with the item on the right-hand side. The right-hand item can be a specific value.
The criteria will pass if the left is greater than or exactly equal to the right. Crossed above
compares the item on the left-hand side of the criteria with the item on the right-hand side. The right-hand item can be a specific value.
The criteria will pass if the left is greater than the right, but on the previous bar the left had been less than the right.
In last bars
You can also specify a number of bars to check in which case the criteria will pass if it is true on any one of the bars. Crossed below
compares the item on the left-hand side of the criteria with the item on the right-hand side. The right-hand item can be a specific value.
The criteria will pass if the left is less the right, but on the previous bar the left had been greater than the right.
In last bars
You can also specify a number of bars to check in which case the criteria will pass if it is true on any one of the bars. Has been above
compares the item on the left-hand side of the criteria with the item on the right-hand side. The right-hand item can be a specific value.
The criteria will pass if the left has been greater than the right on each of the number bars specified. Has been below
compares the item on the left-hand side of the criteria with the item on the right-hand side. The right-hand item can be a specific value.
The criteria will pass if the left has been less than the right on each of the number bars specified. Highest in
compares the item on the left-hand side of the criteria for the number of bars specified.
The critieria will pass if the latest value is greater than all the values for the previous bars. Lowest in
compares the item on the left-hand side of the criteria for the number of bars specified.
The critieria will pass if the latest value is lower than all the values for the previous bars. Increasing for
compares the item on the left-hand side of the criteria for the number of bars specified.
The critieria will pass if each value is progressively higher than the value for the previous bar. Decreasing for
compares the item on the left-hand side of the criteria for the number of bars specified.
The critieria will pass if each value is progressively lower than the value for the previous bar. Occurred on latest or in previous
is used for date-based criteria and compares the item on the left-hand side of the criteria for the latest bar and the number of previous bars specified.
For example, to include stocks which have traded on the latest trading day or on either of the two previous trading days you could specify 'Trade Date occured on latest or in previous 2 bars'. Stocks which have not traded for 3 days would be ignored. Present
is used for text-based criteria and compares the item on the left-hand side of the criteria to see whether a value has been set.
For example, you could specify 'Sector present' to select stocks which have been assigned to Sectors. Not present
is used for text-based criteria and compares the item on the left-hand side of the criteria to see whether a value has been set.
For example, you could specify 'Sector not present' to select stocks which have not been assigned to Sectors. True
is used for pattern-based criteria.
For example, you may have created a Stock Pattern with various criteria and called it 'My Pattern'. In the screen criteria you would then specify a criteria of 'My Pattern true' and the criteria in the pattern would be evaluated in addition to the other criteria in the screen. Customize Criteria You can enter separate criteria for Buy, Sell, Short Sell, or Cover Short. The Buy criteria will show first by default. Click the links next to 'Show criteria for' to access the others.
You must enter at least one criteria under either Buy or Short Sell to get any results.
Enter as many criteria pairs as you need to narrow down your entries and exits. To enter a new criteria on the criteria builder first click 'New Criteria', choose your required Fundamental / Technical Indicator Item, then select the Condition to apply, and finally choose a right-hand Fundamental / Technical Indicator Item or Specific Value to compare to.
Click 'Run Test...' to save all of your changes and display the new results.
To adjust the settings of an existing left or right criteria Item just click on the Item to display the details popup. For example, to change an Item containing EMA(50) to EMA(100), first click on EMA(50), change the Period to 100, close the popup, and click 'Run Test...' to apply. Positions Starting Equity
Is the amount of the cash in the portfolio at the beginning of the Test.
Choose an amount which is appropriate according to your position sizing and maximum positions settings. If the amount is too low the testing engine may not have sufficient cash to enter positions even though a Buy/Short signal is found.
Position Sizing
Five position sizing algorithms are available:
- Fixed number of shares - means that all trades are entered with the same number of shares regardless of the price or volatility of the stock
- Fixed cash amount - means that all trades have the same cash value, so high-priced stocks will have a smaller number of shares than low-priced stocks
- Fixed percentage of Starting Equity - is similar to Fixed cash amount, except that the amount is a specified percentage of starting equity
- Fixed percentage of Current Equity - allows you to vary the cash amount of each trade depending on the performance of the portfolio. In other words increase cash amounts when the portfolio produces profits, and decrease when losses occur
- % of Current Equity to risk - allows you to control position sizes depending on the performance of the portfolio and the volatility of each stock. See the % of Current Equity section below for an example.
Long and Short Amounts
Long and short positions can have different settings. Eg 1000 shares for Long and 500 for Short. For Shorts, if no amount is specified the Long amount is used.
% of Current Equity to Risk
This position sizing choice allows you to control position sizes depending on the performance of the portfolio and the volatility of each stock.
For example, you may choose to risk 2% of current equity on each trade with a stop loss of 3 ATRs:
If the Current Equity is 100,000 then the amount to be risked is 2,000. In other words, the stop should be hit if you lose 2,000 or more on the trade. If the stock has a current ATR of 0.50 you calculate the number of shares to trade as follows:
Shares = 2,000 / (3 * 0.50) = 1,333.33 = 1,330 (rounded to nearest 10)
Working backwards, if the stop of 3 * 0.50 is hit then a loss of 1,995 will result. (Slightly different from 2,000 due to the share rounding.)
Maximum Open Positions
Is the maximum number of open positions at any one time during the test. If Buy/Short signals are found but there are insufficient position slots available, the signals will be ignored.
Maximum New Positions in One Day
Is the maximum number of new positions that can be entered on one day of the test. If Buy/Short signals are found but there are insufficient new position slots available, the signals will be ignored.
Prioritize Symbols
Often there will be more potential trades available for a particular day than there are position slots available. (Based on the Maximum Open Positions and Maximum New Positions in One Day settings.) Choose how you would like to prioritize stocks in such a situation. This is similar to running a screen and then sorting by one of the columns.
Position Entry
You can choose to enter trades at the close of the day when the signal is found or at the open of the following day. Please note that this option applies to Buy and Short. Stops and Targets have their own options.
Position Exit
You can choose to exit trades at the close of the day when the signal is found or at the open of the following day. Please note that this option applies to Sell and Cover. Stops and Targets have their own options.
Existing Position can be Switched
Usually, if a stock is already in a position then it can only be closed by stops, targets, or sell or cover short criteria.
However, you may have a strategy where you want a symbol to be in a trade all the time. For example you could have a strategy which contains only Buy and Short Sell criteria. Once a symbol is in a position then, depending on the criteria, it would continually close the existing position and enter a new one in the opposite direction (E.g. long to short or short to long). In this case you would need to set this option.
Position Size Rounding
Certain position sizing choices may result in part quantities. Choose how you wish to round the positions. Stops and Targets Stop Loss
Stops can be set based on percentages or ATR movements. Separate settings are available for Long and Short positions. You can also specify the timing of the exit and therefore the price to be used.
Trailing Stop Loss
Trailing Stops can be set based on percentages or ATR movements. Separate settings are available for Long and Short positions. You can also specify the timing of the exit and therefore the price to be used.
Trailing Stop Loss uses Close or High Price
When calculating the trailing loss you can choose whether it should use the best close price achieved during the trade or the best high price (low for shorts).
Target Stop
Target Stops can be set based on percentages or ATR movements. Separate settings are available for Long and Short positions. You can also specify the timing of the exit and therefore the price to be used.
ATR Stops Period
If you set ATR stops, the period for the average true range calculation is also required.
Time Stops
Time Stops will cause a position to be closed after the specified number of days. Separate settings are available for Long and Short positions. You can also specify the timing of the exit and therefore the price to be used. Costs Entry Costs %
Enter percentage adjustments to account for entry costs, ie brokerage. For example, an Entry Costs % of 0.1 on a trade which has a value of 10,000usd will result in an additional 10usd cost.
Exit Costs %
Enter percentage adjustments to account for exit costs, ie brokerage. For example, an Exit Costs % of 0.1 on a trade which has a value of 10,000usd will result in an additional 10usd cost.
Slippage %
Depending on your broker and method of trading, you may not always get the strategy prices. You can specify a Slippage % to reflect this.
For example, a Slippage % of 0.2 will mean that all entry and exit prices are adjusted, for example, a Buy price of 25usd will become 25.05usd. All prices are affected including stops. Test Period Test Period
Is the ranges of dates over which the test should run. You can specify fixed dates or a number of trading days. Run Test Click 'Run Test...' when you have completed all changes.
The length of time the test takes to run depends on the complexity and test period.
Once your Test has completed running you can view summary results in the Grid below and detailed information on the other tabs on this page. Customize Grid Columns Click 'Customize Grid Columns' to open or close the Grid customization panel.
To add a new Column click 'Add New Column'. For example, you may wish to add Volume to the Grid. First click 'Add New Column', select Volume, close the details popup, and then 'Apply...' and the Grid will be extended to show Volume.
Use the Up and Down buttons to re-arrange the Column order within the Grid.
To adjust the settings of an existing Column just click on the Column to display the details popup. For example, to change a Column containing EMA(50) to EMA(100), first click on EMA(50), change the Period to 100 and click an 'Apply...' button to save. The Number of static Columns setting determines how the Grid is laid out and is especially useful to prevent horizontal scrolling on devices with narrow screen width.
- the default setting of 'Auto' will mean that an assessment of device width will be made to determine how many static columns can fit with any excess columns shown in 2x2 form format.
- a setting of, for example, 4 will result in the first 4 columns appearing in column format with any subsequent columns shown in 2x2 form format
- a setting of 'Never' will result in no collapsing to form layout
This setting is held at the device level and applies to all Grids across all views.
|
Customize Criteria and Run Test
Create a long position when the following criteria is met
If you combine 'AND' and 'OR' then you may need to include brackets to indicate logical groupings.
For example, Criteria1 OR Criteria2 AND Criteria3 should be specified as (Criteria1 OR Criteria2) AND Criteria3.
Enable and/or logic
Nasdaq GM Nasdaq GS NYSE Buy: Close greater than 0 and Random (1 10000) less than or equal to 10
Nasdaq GM Nasdaq GS NYSE Buy: Close greater than 0 and Random (1 10000) less than or equal to 10
Format
Test Number | Test Time | Test Status | Test Period | Starting Equity | Position Sizing | Prioritize Symbols | Total Profit | Open Profit | Return On Equity % | Annualized Return % | Max Drawdown % | Sharpe Ratio | Number of Closed Trades | Percent Profitable | Average Days in Trade | Winners Profit | Losers Profit | Winning / Losing Profit Ratio | Average Winning / Losing Profit Ratio | Number Of Winners | Number Of Losers | Largest Winner Profit | Largest Loser Profit | Average Winners Profit | Average Losers Profit | Longest Winner Days | Longest Loser Days | Average Length of Winning Trades | Average Length of Losing Trades | Most Consecutive Winners | Most Consecutive Losers |
---|
Page size: Page 1 of 1. Rows 1 to 1 of 1. | 1 | 4/25/2015 2:12 AM | Complete | 60 Days - Latest | 1,000,000 | 10L 10S % Starting Equity | Highest Random (1 10000) | 73,579.15 | 38,676.10 | 7.36 | 35.17 | -1.93 | 0.00 | 9 | 44.44 | 22.67 | 59,857.34 | -24,954.29 | 2.40 | 3.00 | 4 | 5 | 14,997.17 | -4,999.64 | 14,964.34 | -4,990.86 | 45 | 43 | 26.25 | 19.80 | 2 | 4 | Test Number | 1 | | Test Time | 4/25/2015 2:12 AM | Test Status | Complete | | Test Period | 60 Days - Latest | Starting Equity | 1,000,000 | | Position Sizing | 10L 10S % Starting Equity | Prioritize Symbols | Highest Random (1 10000) | | Total Profit | 73,579.15 | Open Profit | 38,676.10 | | Return On Equity % | 7.36 | Annualized Return % | 35.17 | | Max Drawdown % | -1.93 | Sharpe Ratio | 0.00 | | Number of Closed Trades | 9 | Percent Profitable | 44.44 | | Average Days in Trade | 22.67 | Winners Profit | 59,857.34 | | Losers Profit | -24,954.29 | Winning / Losing Profit Ratio | 2.40 | | Average Winning / Losing Profit Ratio | 3.00 | Number Of Winners | 4 | | Number Of Losers | 5 | Largest Winner Profit | 14,997.17 | | Largest Loser Profit | -4,999.64 | Average Winners Profit | 14,964.34 | | Average Losers Profit | -4,990.86 | Longest Winner Days | 45 | | Longest Loser Days | 43 | Average Length of Winning Trades | 26.25 | | Average Length of Losing Trades | 19.80 | Most Consecutive Winners | 2 | | Most Consecutive Losers | 4 |
|
|