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

June 2009 Stocks and Commodities Traders Tips

Average True Range Trailing Stops

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, “Average True Range Trailing Stops” by Sylvain Vervoort, for the average true range (ATR) trailing stop and the modified average true range (ATRM) trailing stop, is shown below.

The ATR stop codes provided can be pasted into any system of your choice and then used as the exit. 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. This stop can be plotted on a chart for purposes of checking trades one at a time. Be sure to set all the inputs to match your objective.

AIQ EDS Code for ATR Trailing Stops:

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, “Average True Range Trailing Stops” by Sylvain Vervoort, is shown below. The average true range (ATR) trailing stops should have an advantage over the fixed percentage trailing stops that were tested in the May 2009 Traders’ Tips article since the stop can adapt to the changing volatility of both the overall market and also adjust to each individual stock’s volatility and changes in volatility. In my May 2009 Traders’ Tip, I modified the system by adding market timing and also traded both the long and short sides. This system, if traded both long and short, would be always in, but since I added a market timing filter based on a general market trend following filter, it will only trade long when the market trend is up and short when the market trend is down. 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 unadjusted price series as well as the split-adjusted series are available in the tests. This can make a big difference in the computation of commissions where they are based on the number of shares traded e.g. Interactive Brokers and TradeStation both compute commissions on a cents per share basis. 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 both long and short using a trend filter on the SPX with optimized parameters using the May 2009 fixed percentage trailing stop system, while the one on the right shows the modified ATR trailing stop (ATRM) system with optimized parameters. Just from looking at the two equity curves, it is hard to tell which is preferable although the ATRM (right curve) appears smoother with smaller draw downs. Looking at Table 1, which shows some key metrics for the two trailing stop methods, we see that the ATRM stops are preferable since we obtain slightly more net profit with lower drawdown, better profit factor and better profit to maximum draw down ratios with fewer trades. I also found that there is a slight improvement (not shown) by using the ATRM system versus the ATR system.

To measure the robustness of the parameter sets from the ATRM system optimization, 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 ATR length parameter is less sensitive to changes than the ATR multiple. The range of good parameters is 5 to 10 days for the ATR length and 4.5 to 5.5 for the ATR multiple. All tests used 300 days for the moving average length on the SPX trend filter. I used the TradersStudio add-in to produce the three-dimensional models.

Traders Studio Code for ATR Trailing Stops:
ATR Trailing














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