SMEP Case Study #1
Home Page
Games
Stock Market


Courtesy www.bigcharts.com

Above is historical chart for Gamestop [GME] in the period between 5/22/06 to 5/22/09. The closing prices are displayed in the upper region and volume is displayed in the lower region.

The data to the left of the vertical bar precedes a stock split and will be ignored in our evaluation.

SMEP Objective:

A visual observation of closing price data between 4/05/07 and 5/22/09 indicates numerous opportunities to earn and lose money buying this stock. The objective is to use the SMEP scripting language (SMSL) to develop a set of rules that will increase the return on the investment and to minimize losses.

Basic Script

              #include base1.txt

              SetSellGain(6.0)
              SetSellLoss(-10.0)
              SetFee(7.00)
              SetInitAmount(1000)

              //downloads  data
              Download(GME, 04/11/07, 05/25/09)	

              //clears worksheet 'StockData'
              Clear(StockData)	  

              //Loads stock data into worksheet
              Load(GME.CSV, StockData)

              //Adds column - seems redundant but is necessary
              //Three arguments: name of worksheet, name of 
              //column (placed at the top), and column number
              AddCol(StockData, Date, 1)
              AddCol(StockData, Open, 2)
              AddCol(StockData, Volume, 3)
              AddCol(StockData, High, 4)
              AddCol(StockData, Low, 5)
              AddCol(StockData, Close, 6)
              AddCol(StockData, Buy, 7)
              AddCol(StockData, Sell, 8)
              AddCol(StockData, Comment, 9)
              AddCol(StockData, CMA20, 10)
              AddCol(StockData, CMA6, 11)
              AddCol(stockData, VMA10, 12)

              CMA20 = SMA(Close, 20)
              CMA6 = SMA(Close, 6)
              VMA10 = SMA(Volume, 10)

              FillCol(Buy, 1)
              FillCol(Sell, 1)
              

For the purpose of this case study I'm only going to use three calculations. CMA20 is simple moving average of 20 days, CMA6 is a SMA of 6 days, and VMA10 is a SMA of volume for 10 days.

Buy and Sell Rules #1

              Buy = LogicX(Close > CMA20)
              Sell = LogicX(Close < CMA20)
              

For this example we'll buy when the closing price rises above the 20 day moving average. We'll sell the stock when the closing price drops below the 20 day moving average. Given a $1000 initial investment the following results are achieved.

              Stock Symbol:          GME
              Number of shares held: 0
              Current share price:   22.55
              Total value:           435.73
              Gain/Loss:             -56.427%
              

Ugly! Our rules resulted in a 56% loss. Our $1000 is now worth $435. As you can see, the chief advantage of SMEP is that you can experiment with various rules for buying or selling "algorithms". You can then apply these rules against historical stock data to determine the effectiveness of your algorithm.

Buy and Sell Rules #2

              Buy = LogicX(Close > CMA20)
              Buy = LogicX(Volume > VMA10)
              Sell = LogicX(Close < CMA20)
              

We'll modify the buying rule to state that a buy will only happen if the volume for the day is greater than the 10 day moving average of volume.

              Stock Symbol:          GME
              Number of shares held: 0
              Current share price:   22.55
              Total value:           786.060000000001
              Gain/Loss:             -21.3939999999999%
              

Still a bit dismal but not as bad as before. The goal is to continue tweaking rules in order to find something that will increase gains when the stock price in the graphic above rises. In addition, losses should be further minimized.

Buy and Sell Rules #3

              Buy = LogicX(CMA6 > CMA20)
              Buy = LogicX(Volume > VMA10)
              Sell = LogicX(Close < CMA6 & CMA6 < CMA20)
              Sell = LogicX(Volume > VMA10)
              

I skipped through an hour or so of experimentation and posted my latest algorithm for buying and selling. The results are displayed below.

              Stock Symbol:          GME
              Number of shares held: 0
              Current share price:   22.55
              Total value:           1382.48
              Gain/Loss:             38.248%
              

Wow! We've developed a method to make a lot of money on a stock that is riding a roller coaster. Over a two year period the gain is 19%.

Conclusion

Stocks typically follow particular patterns in various markets. It's possible to create algorithms that work well for specific patterns.

Copyright 2009