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.
|