To Find a Generalized Equation to Determine a Stock's Optimal Trailing Stop Loss using Linear Regression

CSEF · 2007 Mathematics & Software Second Award

Overview

Objectives/Goals Trailing stop loss is a technology that provides investors with an exit strategy that can help to maximize profits. The purpose of this project was to find an equation in the form OTSL = m*(HPV) + b where OTSL is a stock's optimal trailing stop loss, and HPV is its historical price volatility over a one year period. Methods/Materials A template spreadsheet was set up to take the raw data of 20 stocks from 2004-07. The values were copied onto the spreadsheet, and it generated several other columns based on this initial data including absolute gain since simulated buying day (in 2004) and daily gain or loss as a percentage. A running maximum column was generated to show the highest stock price since buying day, and another called dip percentage showed by what percentage each day's price had dipped from the running maximum. Each stock's volatility was calculated by finding the standard deviation of the values in the day to day percentage gain/loss column from 2003-04 and multiplying that by the square root of 252. Each one's OTSL was calculated by finding the value in the dip percentage column that would allow that stock to ride for the amount of time that would give it the highest obtainable gain. The OTSL and HPV values obtained from the 20 tested stocks were entered into a regression table, generating a linear equation. The accuracy of this equation was checked by using back-testing - finding the HPVs of 10 stocks, entering them into the equation, and comparing the outputted OSTL of each stock to its actual OSTL. Real-time accuracy testing was also done by finding the HPVs of 10 stocks from 2006-07, getting their predicted OTSLs, and setting each stock with its generated OTSL using virtual trading. Resources used in this project were finance.yahoo.com, for its historical data; Microsoft Excel; and optionsxpress.com, for its virtual trading interface. Results The R^2 of the regression was 0.8, proving that OTSL and HPV are related. The back-testing used to check the equation was successful, as most of the generated OSTLs were within 1-3% of the actual OSTLs. The results of the real-time testing were good as well, with the ten stocks going up as a whole by an annualized 30%. Conclusions/Discussion It was discovered that there is indeed a solid relationship between a stock's OTSL and its HPV, and that it is possible to determine an accurate linear equation to predict a stock's OTSL based on its volatility.

Summary statement

This project was about developing a generalized equation that could calculate a stock's optimal trailing stop loss using its historical price volatility.

Help received

Father helped check abstract and board material; showed where to obtain stock data; helped with strategies to effectively utilize Excel

Awards (1)

Competition history

  • CSEF 2007 Mathematics & Software · Entry J1319

Resources

Related projects

Closest projects by meaning, across every fair and year in the corpus.

Browse more like this

Source: California Science & Engineering Fair public projects

Save projects to your library

Sign in with Google to keep track of projects you find interesting, organized into folders. An account also raises your daily allowance for “Has this been done?”, and lets you create a key for the MCP server with a much higher limit than anonymous use. Browsing stays public.

Continue with Google