TradersEdgeSystems.com

Consulting | Custom Trading Systems
Built-In Indicators | Custom Indicators

May 2009 Stocks and Commodities Traders Tips


Using Initial Stop Methods

Original article by Sylvain Vervoort
AIQ Code by Richard Denning
Traders Studio Code by Richard Denning

AIQ Version:

The AIQ code for the date specific version in the article, “Using Initial Stop Methods” by Sylvain Vervoort, is shown below.

To use a fixed percent trailing stop in a back test in AIQ, a built-in stop of this nature is provided. Consequently, this type of stop does not need to be coded to be used in either the EDS module or the Portfolio Manager module. The date specific (a start date is manually entered in the EDS code as an input and then the stop starts trailing as of that date) has been coded and provided below. Be sure to set all the inputs to match your objective.

In Figure 1, I show a chart of APOL with an arbitrary entry long on 10/2/2009 at the close. The 14 percent trailing stop then starts on that date and the close stays above the trailing stop until 2/19/2009. This was one of the few trades long that worked out during this time period.

Captions for AIQ Figures:
Figure 1: APOL with 14 percent trailing stop from arbitrary entry date of 10/2/2008. Trailing stop was touched on 2/19/2009 which triggered an exit for a profit of 31%.

AIQ EDS Code for Using Initial Stop Methods:
InitialStops_Date.EDS



Traders Studio Version:

The TradersStudio code for the fixed-percentage trailing stop trading system and also the date specific version along with the indicator code and the related functions in the article, “Using Initial Stop Methods” by Sylvain Vervoort, is shown below. The fixed-percentage trailing stop trading system is interesting in that it is very simple and has only one parameter. This system, if traded both long and short, would be always in, but the author only trades the long side of the system. The author tested the system in a period that contained mostly a long-term uptrend as the test period started in 2003 and ended on 11/10/2008. The results from 10/01/08 to 3/13/09 are not good and it would seems to me that both the long and short side should be traded based on some type of general market trend following filter. Consequently, the coded version that I have supplied has the options of trading either long only, short only or both long and short and also has the option to apply a market trend filter using the S&P 500 index (SPX) to determine whether to trade long or short. I decided to stick with the author’s list of stocks for the tests. One major advantage to testing with TradersStudio on stocks is that both the original unadjusted price series is available in the tests as well as the split adjusted series. This can make a big difference in the computation of commissions where they are computed based on the number of shares traded such as is the case with Interactive Brokers and TradeStation. Unless you know the actual price of the stock and the actual number of shares that would have been traded, commissions can not be computed accurately for brokers like Interactive and TradeStation. Also we are able to correctly apply a minimum price rule to eliminate very low priced stocks. When only split adjusted data is available, we can not accurately apply a price filter because we don’t know whether a stock is low priced due to a split or was really trading at a low price in real time. TradersStudio also has the ability to compute the dividends that you would have been received or paid (if short).

In Figure 1, I show a comparison of the equity curves, the left one represents trading long only with the author’s parameter of 14 percent versus the equity curve on the right which represents trading both long and short using a trend filter on the SPX with optimized parameters. To measure the robustness of the parameter sets from the modified system, I show in Figure 2, two three dimensional models. The left model shows the two parameters compared to the net profit and the right model shows the two parameters compared to the maximum draw down. The percent trailing parameter is less sensitive to changes than the market timing trend filter. The range of good parameters is 17 to 23 percent for the percent trailing stop and 200 to 300 days for the moving average length on the SPX trend filter. I used the TradersStudio add-in to produce these three dimensional models.

Captions for Traders Studio Figures:
Figure 1: Comparison of equity curves – original system (long only) on left versus modified system that trades both long and short and uses a market timing trend filter on right.

Figure 2: Three dimensional parameter maps of the modified system for the two parameters compared to net profit on left and maximum draw down on right.

Traders Studio Code for Using Initial Stop Method:
Initial_Stops_Methods_TSZ.zip

 

 

 

 

 

 

 

 

 

 

 

 

 

Disclaimer | Privacy Policy | Contact Us | Spam Blocker | ©2009 Traders Edge Systems