I am considering having some software written that will contain a number of features that I believe would be a leap forward in systems development (at least to me). Here is a small list of what I would like to accomplish with this software:
1) Stock Screening
---a) Custom language
2) Charting
3) Strategy Development
--- a) Backtesting
--- b) Strategy optimization
--- c) Walk-forward optimization
The requirements listed above are pretty typical and something that many software packages can already provide. Specifically, the charting portion of this software wouldnât be much different than whatâs already out there. What makes this package different is the custom language that will drive its main features. Basically what I want created will allow a user to write pseudo code which allows them to screen stocks, backtest trading ideas, and optimize their trading strategies. Still doesnât sound all that revolutionary, but what I describe here is just the tip of the iceberg. The scope of this project will bring together the best elements of strategy development that are out there.
I think the best way to get across some of what I want to do is to start off with an example of the custom language. In this example a strategy is defined and optimized:
[Backtest]
Approach type is short
Equities account is $50,000.00
If trading Capital falls below $5,000.00, then stop trading
Initial Day Trading Buying Power is $200,000.00
Initial Overnight Buying Power is $100,000.00
Start Date is 10 Apr 1998
End Date is 5 Aug 2003
Bar Interval is 5 minute bars
Intrabar order generation on 1 minute bars
Maximum number of shares per trade is 5,000
Maximum number of open positions is 4
[Commission]
If shares => 500 then commission = $0.01 a share per trade
if shares =< 501 then commission = $0.006 a share + $5.00 per trade
[Slippage]
Use Slippage algorithm 12
[Entry Filter 1]
Maximum number of entries per day is 1
RSI(10) is above 98
RSI(5) has been decreasing for 2 days
Close is between $6.50 and $400.00
Average Volume(10) is above 500,000
Add column RSI(2) to chart
Add column RSI(5) to chart
Add indicator RSI(2) to chart
Add indicator RSI(5) to chart
[Entry Selection Criteria, Entry Filter 1]
Close descending
[Exit Filter 1]
MA(5) has been increasing for 2 days
[Exit Selection Criteria, Exit Filter 1]
MACD fast line(3,6) ascending
[Money Management]
Fixed Fractional amount is 11% of the Equities Account per trade
Trailing Stop is 2% per trade
Profit Stop is 20% with a trailing stop of 1.5% per trade once the profit target is reached
Time Stop is 10 days
Break-even Stop is off
[Optimization Settings]
The Optimization method is brute force
Objective Function is PROM Minus
Maximum Drawdown per trade is 20%
Maximum Drawdown for strategy is 15%
The minimum Degrees of Freedom for the strategy is 90%
The maximum amount of time the strategy is allowed to optimize is 1 day or less
[Optimize]
Optimize RSI(2 to 99 in steps of 2) is above 2 to 99 in steps of 5
Optimize RSI(2 to 99 in steps of 2) has been increasing for 1 to 10 in steps of 1 days
Optimize Volume is above 500,000 to 2,000,000 in steps of 10,000
Optimize MA(2 to 200 in steps of 10) has been increasing for 2 to 7 in steps of 1 days
Optimize MACD fast line(2 to 20 in steps of 1, 2 to 20 in steps of 1) ascending
Optimize Fixed Fractional amount is 1 to 100 in steps of 1% of Starting Capital per trade
Optimize Trailing Stop is 1 to 100 in steps of 1% of Starting Capital per trade
Optimize Profit Stop is 1 to 50 in steps of 1% with a trailing stop of 1 to 100 in steps of 1% per trade
Optimize Time Stop is 1 to 10 in steps of 1 days
[Walk-Forward]
Walk-Forward analysis is off
The text above essential automates the backtesting and optimization of the strategy. The program looks at the phrase combinations and thatâs what determines how it will act. The different categories (such as backtest, commission, etc.) further refine how a phrase combination will be treated. BTW, please donât too hung up on the actual strategy I defined, I just made it up on the spot for this example. Here is a general description of each category:
[Backtest]
This defines things such as whether or not the strategy is long or short, the account size, start and end date of the backtest, bar interval, intrabar order generation, etc. You can also define a watchlist file here if you want this backtest to be performed on a basket of stocks or a specific market. Generally, this category is used to define the framework in which all the other categories will work with.
[Commission]
The user has the option on how the want to calculate commissions, if any.
[Slippage]
The user has the option on how the want to calculate slippage, if any.
[Entry Filter]
The entry filter describes what criteria need to be met in order to place a trade. There can be multiple entry filters to allow greater flexibility when placing trades, each with their own limitations. Here is another example of an entry filter:
--- [Entry Filter 2]
--- Close is within 2% of the top of a 90 day channel
--- Do not trade on Tuesdays
--- Do not trade between the hours of 09:30 to 10:45
--- Do not trade between the hours of 14:30 to 15:00
[Entry Selection Criteria]
The entry selection criteria defines the order trades will be placed in. For example, say 10 stocks meet the criteria for entry. In the example given the stocks would have been shorted based on the descending close. This is important because if you limit the amount of capital you want to trade via money management, some of those 10 stocks that met the criteria cannot be traded. There is usually an entry selection criteria for each entry filter.
[Exit Filter]
Like the entry filter, this category defines how a trade will be exited. It can be based on an indicator, date, time, and whatever else the user can think of. Exit filters can also be limited to specific entry filters depending on the needs of the user. For example, a strategy has 2 entry conditions, and 10 exit conditions. The user can have two of the exit filters apply only to entry filter 1, and the remaining 8 exit filters apply to both entry filter1 and entry filter 2. This can allow for some very complicated exit techniques.
[Exit Selection Criteria]
Works the same as the entry selection criteria, except for exits.
[Money Management]
The money management category defines stops, the amount of shares to be traded per trade, etc. Pyramiding a trade is further described here. There can be multiple money management techniques defined, each pertaining to a particular entry filter
[Optimization Settings]
The optimization settings category defines the methods used to optimize a backtest. Objective functions can be defined here as well as the optimization type; brute force, genetic algorithm, etc. Minimum and maximum values can be set here as well which define acceptable performance. For instance, while the optimization engine is looking for the highest profit factor the strategy must also make a minimum number of trades to be deemed statistically significant. If this condition is not met, then that iteration is thrown out even if it has the highest profit factor. Another example is that an iteration must not surpass an intraday drawdown limit or else be thrown out.
[Optimize]
This is where the actual parameters are set to be optimized. Numerical variables are replaced with default range of numbers and step values. Users can change these values to suite their needs or leave them default. Items like descending, ascending, increasing, decreasing, true, false can also be optimized.
[Walk-Forward]
Walk forward testing can be defined here and automatically conducted. Here is an example of the walk-forward category:
--- [Walk-Forward]
--- The Estimation Window is 50% the size of the backtest period
--- The Test Window size is 12.5% the size of the backtest period
--- The Step Window size is 12.5% the size of the backtest period
1) Stock Screening
---a) Custom language
2) Charting
3) Strategy Development
--- a) Backtesting
--- b) Strategy optimization
--- c) Walk-forward optimization
The requirements listed above are pretty typical and something that many software packages can already provide. Specifically, the charting portion of this software wouldnât be much different than whatâs already out there. What makes this package different is the custom language that will drive its main features. Basically what I want created will allow a user to write pseudo code which allows them to screen stocks, backtest trading ideas, and optimize their trading strategies. Still doesnât sound all that revolutionary, but what I describe here is just the tip of the iceberg. The scope of this project will bring together the best elements of strategy development that are out there.
I think the best way to get across some of what I want to do is to start off with an example of the custom language. In this example a strategy is defined and optimized:
[Backtest]
Approach type is short
Equities account is $50,000.00
If trading Capital falls below $5,000.00, then stop trading
Initial Day Trading Buying Power is $200,000.00
Initial Overnight Buying Power is $100,000.00
Start Date is 10 Apr 1998
End Date is 5 Aug 2003
Bar Interval is 5 minute bars
Intrabar order generation on 1 minute bars
Maximum number of shares per trade is 5,000
Maximum number of open positions is 4
[Commission]
If shares => 500 then commission = $0.01 a share per trade
if shares =< 501 then commission = $0.006 a share + $5.00 per trade
[Slippage]
Use Slippage algorithm 12
[Entry Filter 1]
Maximum number of entries per day is 1
RSI(10) is above 98
RSI(5) has been decreasing for 2 days
Close is between $6.50 and $400.00
Average Volume(10) is above 500,000
Add column RSI(2) to chart
Add column RSI(5) to chart
Add indicator RSI(2) to chart
Add indicator RSI(5) to chart
[Entry Selection Criteria, Entry Filter 1]
Close descending
[Exit Filter 1]
MA(5) has been increasing for 2 days
[Exit Selection Criteria, Exit Filter 1]
MACD fast line(3,6) ascending
[Money Management]
Fixed Fractional amount is 11% of the Equities Account per trade
Trailing Stop is 2% per trade
Profit Stop is 20% with a trailing stop of 1.5% per trade once the profit target is reached
Time Stop is 10 days
Break-even Stop is off
[Optimization Settings]
The Optimization method is brute force
Objective Function is PROM Minus
Maximum Drawdown per trade is 20%
Maximum Drawdown for strategy is 15%
The minimum Degrees of Freedom for the strategy is 90%
The maximum amount of time the strategy is allowed to optimize is 1 day or less
[Optimize]
Optimize RSI(2 to 99 in steps of 2) is above 2 to 99 in steps of 5
Optimize RSI(2 to 99 in steps of 2) has been increasing for 1 to 10 in steps of 1 days
Optimize Volume is above 500,000 to 2,000,000 in steps of 10,000
Optimize MA(2 to 200 in steps of 10) has been increasing for 2 to 7 in steps of 1 days
Optimize MACD fast line(2 to 20 in steps of 1, 2 to 20 in steps of 1) ascending
Optimize Fixed Fractional amount is 1 to 100 in steps of 1% of Starting Capital per trade
Optimize Trailing Stop is 1 to 100 in steps of 1% of Starting Capital per trade
Optimize Profit Stop is 1 to 50 in steps of 1% with a trailing stop of 1 to 100 in steps of 1% per trade
Optimize Time Stop is 1 to 10 in steps of 1 days
[Walk-Forward]
Walk-Forward analysis is off
The text above essential automates the backtesting and optimization of the strategy. The program looks at the phrase combinations and thatâs what determines how it will act. The different categories (such as backtest, commission, etc.) further refine how a phrase combination will be treated. BTW, please donât too hung up on the actual strategy I defined, I just made it up on the spot for this example. Here is a general description of each category:
[Backtest]
This defines things such as whether or not the strategy is long or short, the account size, start and end date of the backtest, bar interval, intrabar order generation, etc. You can also define a watchlist file here if you want this backtest to be performed on a basket of stocks or a specific market. Generally, this category is used to define the framework in which all the other categories will work with.
[Commission]
The user has the option on how the want to calculate commissions, if any.
[Slippage]
The user has the option on how the want to calculate slippage, if any.
[Entry Filter]
The entry filter describes what criteria need to be met in order to place a trade. There can be multiple entry filters to allow greater flexibility when placing trades, each with their own limitations. Here is another example of an entry filter:
--- [Entry Filter 2]
--- Close is within 2% of the top of a 90 day channel
--- Do not trade on Tuesdays
--- Do not trade between the hours of 09:30 to 10:45
--- Do not trade between the hours of 14:30 to 15:00
[Entry Selection Criteria]
The entry selection criteria defines the order trades will be placed in. For example, say 10 stocks meet the criteria for entry. In the example given the stocks would have been shorted based on the descending close. This is important because if you limit the amount of capital you want to trade via money management, some of those 10 stocks that met the criteria cannot be traded. There is usually an entry selection criteria for each entry filter.
[Exit Filter]
Like the entry filter, this category defines how a trade will be exited. It can be based on an indicator, date, time, and whatever else the user can think of. Exit filters can also be limited to specific entry filters depending on the needs of the user. For example, a strategy has 2 entry conditions, and 10 exit conditions. The user can have two of the exit filters apply only to entry filter 1, and the remaining 8 exit filters apply to both entry filter1 and entry filter 2. This can allow for some very complicated exit techniques.
[Exit Selection Criteria]
Works the same as the entry selection criteria, except for exits.
[Money Management]
The money management category defines stops, the amount of shares to be traded per trade, etc. Pyramiding a trade is further described here. There can be multiple money management techniques defined, each pertaining to a particular entry filter
[Optimization Settings]
The optimization settings category defines the methods used to optimize a backtest. Objective functions can be defined here as well as the optimization type; brute force, genetic algorithm, etc. Minimum and maximum values can be set here as well which define acceptable performance. For instance, while the optimization engine is looking for the highest profit factor the strategy must also make a minimum number of trades to be deemed statistically significant. If this condition is not met, then that iteration is thrown out even if it has the highest profit factor. Another example is that an iteration must not surpass an intraday drawdown limit or else be thrown out.
[Optimize]
This is where the actual parameters are set to be optimized. Numerical variables are replaced with default range of numbers and step values. Users can change these values to suite their needs or leave them default. Items like descending, ascending, increasing, decreasing, true, false can also be optimized.
[Walk-Forward]
Walk forward testing can be defined here and automatically conducted. Here is an example of the walk-forward category:
--- [Walk-Forward]
--- The Estimation Window is 50% the size of the backtest period
--- The Test Window size is 12.5% the size of the backtest period
--- The Step Window size is 12.5% the size of the backtest period