I was catching up on some of my Wired reading this morning when I came across an article about automagic stock investing. One of the links from the article was to a site called Wealth-lab. It is essentially a trading simulator/community where people can develop trading scripts and strategies and then simulate their usage. For example here is a script titled “BREAD & BUTTER #6: Swing Trading the Gap” written by somebody named quester ( I love the grown up names people use on the internet…)
var Bar,QClose,QOpen:integer;
var gap,Qgap:float;
QClose:=GetExternalSeries(’QQQQ’,#Close);
QOpen:=GetExternalSeries(’QQQQ’,#Open);
for Bar:=2 to BarCount-1 do
begin
Qgap:=100*(@QClose[Bar-1]-@QOpen[Bar])/@QClose
[Bar-1];
gap:= 100*(PriceClose(Bar-1)-PriceOpen(Bar))/
PriceClose(Bar-1);
if not LastPositionActive then
if (gap > 5) and (Qgap > 0.5) then
if PriceClose(Bar-1)
BuyAtMarket(Bar,'');
if LastPositionActive then
SellAtStop(Bar+1,PriceClose(Bar),LastPosition,
'');
end;
The above script (code) encodes the following rules:
“Buy a stock when the stock is down the day before, QQQ is gapping down more than half a percent, and the stock is gapping down more than 5 percent.”
“Hold the stock at least until the next morning.”
“Sell when the stock goes lower than the prior day’s close.”
Without examining this language and the whole site in great detail (which I assure you gentle reader, I will be looking into this…) I gather that this script is run at the start and end of each trade day to determine what action should take place for a given stock. This is fantastic, it takes the emotional element out of stock trades. As anybody who has ridden a stock all the way to it being delisted just hoping that it will turn around, you know how important it is to have specific rational trading rules for when to sell and when to buy.