Sunday, 29 July 2012

Week of 2012 JL 27

SPY rose by 1.8% this week, while my account fell 0.2%.  The loss-floor is now -7.9%.

Euro news: On Thursday, Mario Draghi of the ECB said that he would do whatever is needed to save the Euro and ”believe me, it will be enough”.  This pixie dust caused the market to zoom!  For 24 hours.  On Friday, Draghi announced that he would meet with Germany next week to get approval for the money-printing he had just promised.  The market zoomed!  For about 12 hours.  On Saturday, Wolfgang Schäuble of Germany said Nein! as expected.  Will the markets fall on Monday?

US news: The Fed’s committee meets next Wednesday.  The expected result is “no action”.  The markets will probably be up on Tuesday and down on Wednesday.

Friday’s allocations:
Daily % gain
size
Max loss
Sym  Buy Fri Mon Tue Wed Thu Fri Beg   End
 
SRTY ¹  JL20 +0.1  15  +0.1  15  +0.1  15  +0.1  0 
SRTY ²  JL23 -0.2  15  -0.2  15  -0.2  15  -0.2  0  -1.1 -1.1
SRTY ³  JL24 +0.1  15  -0.0  15  -0.0  15  -0.0  15  -1.2 -1.2
UPRO  JL24 +0.0  10  +0.0  10  +0.0  10  +0.0  0  -1.2 -1.2
SPY +8.7   +7.6   +6.7   +6.7   +8.5   +10.5
me -7.7 -7.9 -7.8 -7.9 -7.9 -7.9
floor -7.7 -7.9 -9.0 -7.9 -7.9 -7.9

UPRO: Non-robot day trade.  I successfully caught the end-of-day ramp on Tuesday, but the gain was insignificant.  It seems that UPRO is not a suitable vehicle for these half-hour trades.  Perhaps I need to upgrade my account to ”Options level 1” so I can buy calls instead of shares to increase the leverage.

Stock-trading robot

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual  M  A  M  A
SRTY ¹² JL 20 11:00 $45.50 $45.57 (Do not sell) JL 20 15:00 $45.84 +0.7% -0.1%
(Do not buy) JL 23 11:00 $48.42 JL 23 14:00 $47.90
SRTY ³ JL 24 13:00 $49.69 $49.68 JL 25 10:00 JL 25 10:40 $49.69 -0.1% -0.0%

SRTY ¹²: I would have had a profit for the week if this trade had gone according to model!  New rule: If the model says “keep” but the robot sells, then put in a limit-order to try to get the shares back at the erroneous sale price.  Last Friday I didn’t get home until after the market closed, but the sale price showed up again during the after-hours session so I could have saved this trade.

SRTY ³: Another quote problem.  Used a limit-order to break even.

Quote fetch&archive system:  The problem with SRTY ¹ wasn’t a single wrong quote, but a set of wrong quotes over a period of days, which led to accumulating errors in the indicators.  Previously I was replacing Schwab’s quotes with stockchart.com’s quotes once per week, but apparently an entire week is too long and the indicators can diverge significantly in only a day or two.  Solution: pull replacement quotes from barchart.com once per day.  This worked partially on Wednesday (closing price was wrong, which is part of why SRTY ³ failed), worked correctly on Thursday, then failed Friday because barchart.com decided to show two days of data in response to a request for one day (they fixed this on Saturday).  So now I am using three different sources for quotes, none of which actually does what I need!  Maybe I should move my account to Interactive Brokers.

When will the models give a “buy” signal?

TNA: A day or two at least.  STDDEV(80) is only a little higher than its EMA(43).

TZA: Several days at least.  The short-term trend is up!

URTY: Not for a while.  TRIX(176,15) is approximately zero.

SRTY: Could happen on Monday, if there is a big gap-down followed by an hour’s retrace.

IAU: Could happen next Friday, if current trends continue.  MACD is only slightly negative.

Surfing the oscillations

The US equity markets haven’t gone anywhere since February.  For the last month, IWM (the small-caps) have been in a down-trending channel, while the SPY (the large-caps) have been in an up-trending channel.  As of Friday, IWM has reached the top of its channel, while SPY has burst through the top of its channel.  For next week, I expect either a gap-up to escape from the channel or a corrective bounce-down to stay inside it.

Saturday, 21 July 2012

Week of 2012 JL 20

SPY rose by 0.5% this week, while my account fell 0.7%.  The loss-floor is now -7.7%.

Market news: The bears are licking their chops!  Robert Prechter, of Elliot Wave Theory fame, has started sending out emails about his “drop like a rock scenario”.  Cycle analysis has convinced some traders that the market will start dropping next week, hitting its usual bi-monthly low around August 7th (last year the decline was July 25th..August 9th).  Of course, nothing ever goes as planned on the stock market, so I will wait for a “short” signal from my indicators.

Friday’s allocations:
Daily % gain
size
Max loss
Sym  Buy Fri Mon Tue Wed Thu Fri Beg   End
 
TZA  JL11 -0.6  14  -0.6  14  -0.6  14  -0.6  0 
TNA  JL18 -0.3  15  -0.4  15  -0.8  14  -1.1 -1.0
UPRO  JL19 -0.0  15  -0.0  15  -0.0 -0.0
SRTY  JL20 +0.1  15  -0.9 -0.9
SPY +8.2   +7.9   +8.7   +9.5   +9.7   +8.7
me -7.0 -7.0 -7.0 -7.2 -7.4 -7.7
floor -7.0 -7.0 -7.0 -8.0 -8.0 -7.7

UPRO: Non-robot day trade.  I tried to catch the end-of-day ramp on Thursday, but the ramp was too small and didn’t cover my trading costs.  I did this trade by eye, but afterward it turned out that I would have gotten substantially the same results using MACD(10,30,20) on the 1-minute chart (which I had backtested some months ago).

Stock-trading robot

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual  M  A  M  A
TNA JL 18 13:00 $55.89 $55.91 JL 20 12:00 $52.92 -0.8%
SRTY JL 20 11:00 $45.50 $45.57 (Not yet) JL 20 15:00 $47.00 +0.1%

TNA: Rats!  The stupid model said to buy this at (what turned out to be) Wednesday’s high of the day.  Should reprogram the model to *wait* for a retrace before buying — although in this case that would merely have reduced the loss.

SRTY: The robot’s real-time quotes from Schwab differ by pennies from the model’s on-the-hour quotes from Stockcharts.com.  In this case, the divergence was enough to produce a spurious “sell” signal.  I’m not sure what to do in such cases.  Should I buy back what should not have been sold?  Use a limit order to try to get it back at the sale-price (reducing profit by 0.03% for the two extra transaction fees)?  For now, I have replaced the robot’s quote archive with the model’s data and added a temporary rule to the model:
IF time = "2012-07-20 15:00" THEN sell SRTY
This causes the robot to realize that it doesn’t currently own SRTY, so it will buy anew on Monday if the downtrend resumes.

PPO-based swing trades

How to change the TNA/TZA models so they wait for a retrace after a breakout?  Perhaps I need a new indicator RETRACE(size,significance) which will calculate a retrace of size percent of the distance from the most recent peak to a recent bottom.  Significance would somehow have to define “recent bottom” — perhaps a number of hours of rising prices that must follow it?

Before trying that, I decided to try replacing the PPO-based model with something simpler: how about a TRIX+MACD model?  For my bearish tests on IWM, I ended up using TRIX(22,2) and MACD(10,60,13): short when TRIX < 0 and MACD > 0 and falling; cover when TRIX > 0 or MACD > 0 and rising.  This works okay, but not as well as the PPO-based model.  The problem seems to be that “waiting for the retrace” is not generally a good idea, at least for bearish swings.  I suppose I should try a bullish test, to see whether this approach works better for those, but I haven’t done that.

For last August’s crash, the TRIX+MACD model would have waited until August 2nd before shorting (because that is how long it took for MACD to go briefly above zero before crashing) while the PPO model would have shorted on July 26th.  As a result, the TRIX+MACD model would have increased my account by only 11.5% on that crash, while PPO would have made 18.9%. For 2008..2011 as a whole, the TRIX+MACD model’s TZA profits would have been 31.5%, while the PPO model’s would have been 61.9%.  I think I’ll stick with the PPO model.

To get some use out of this abandoned research, I have added the TRIX rule to the TNA/TZA models.  This helps only slightly: for TNA the four-year profit was 47.7% and win:loss ratio was 29:16, now it’s 50.7% and 29:15.  For TZA the old results were 61.9% and 23:17, now 66.3% and 21:13.  Much of these profit-increases come from retuning the models, since TRIX is blocking some bad trades so now they don’t need to be blocked by other indicators.

Bull swing (TNA) Bear swing (TZA)
Buy signal:
  • Time = 11am–3pm, on the hour
  • PEAKFREQ(140,8) ≤ 11
  • TRIX(23,2) > 0
  • This hour’s price > 99.9% of previous hour’s price
  • This hour’s price > stop
  • This hour’s price > SMA(30)
  • This hour’s price > max of preceding 26 hourly prices
  • PPO(8,71,1) < +2.0
  • PPO(8,71,12) > +0.4
  • PPO(8,71,12) has gone below -0.25 since last sale
  • STDDEV(80) < its EMA(43)
  • Time = 10am–3pm, on the hour
  • PEAKFREQ(140,8) ≤ 11
  • TRIX(23,2) < 0
  • This hour’s price < 100.1% of previous hour’s price
  • This hour’s price < stop
  • This hour’s price < SMA(77)
  • This hour’s price < min of preceding 32 hourly prices
  • PPO(10,57,1) > -2.0
  • PPO(10,57,10) < -0.1
  • PPO(10,57,10) has gone above +0.28 since last sale
  • STDDEV(29) < its EMA(25)
Alternate buy signal:
  • Time = 11am–3pm, on the hour
  • This hour’s price > SMA(30)
  • This hour’s PPO(8,71,12) minus its value from 35 hours ago > +2.6
  • It has been at least 6 hours since last sale.
  • Time = 10am–3pm, on the hour
  • This hour’s price < SMA(77)
  • This hour’s PPO(10,57,10) minus its value from 22 hours ago < -2.35
  • It has been at least 10 hours since last sale.
Buy-more signal:
  • Time = 10am–4pm, on the hour
  • Either
    • PPO(8,71,12) has risen by at least 0.006 during each of the last two hours
    • PPO(8,71,12) has changed by less than ±0.006 during the last hour and rose by at least 0.006 during each of the preceding two hours
  • PPO(8,71,12) fell by at least 0.006 during the two hours before that.
  • STDDEV(80) < its EMA(43)
  • Have bought 2 or fewer tranches so far
  • If signal received at 10am or 4pm, postpone purchase to 11am
  • Time = 10am–4pm, on the hour
  • Either
    • PPO(10,57,10) has fallen by at least 0.025 during each of the last two hours
    • PPO(10,57,10) has changed by less than ±0.025 during the last hour and fell  by at least 0.025 during each of the preceding two hours
  • PPO(10,57,10) rose by at least 0.025 during the two hours before that.
  • STDDEV(29) < its EMA(25)
  • Have bought 4 or fewer tranches so far
  • If signal received at 4pm, postpone purchase to 10am 10am or
Sell signal:
  • Time = 11am–3pm, on the hour
  • 99.9%  of this hour’s price < previous hour’s price
  • This hour’s PPO(8,71,12) < -0.25
  • PPO(8,71,12) has gone above +0.4 since original purchase
  • Time = 10am–3pm, on the hour
  • 100.1% of this hour’s price > previous hour’s price
  • This hour’s PPO(10,57,10) > +0.30
  • PPO(10,57,10) has gone below -0.1 since original purchase
Alternate sell signal:
  • Time = 11am–3pm, on the hour
  • This hour’s PPO(8,71,12) minus its value from 35 hours ago < -2.05
  • It has been at least 6 hours since last purchase.
  • Time = 10am–3pm, on the hour
  • This hour’s PPO(10,57,10) minus its value from 22 hours ago > +0.58
  • It has been at least 10 hours since last purchase.
Stop update:
  • Time = 10am
  • Calculate new stop = lowest price seen in preceding 22 hours.
  • Raise new stop to 95.0% of the highest price seen in preceding 22 hours, if less than that
  • If I don’t currently own TNA, replace stop with the newly-calculated value.  Otherwise:
    • Discard new stop (and keep the old one) if the new value is lower
    • Sell now if lowest price of last 22 hours occurred during the last hour
    • Otherwise, convert the IWM-based stop to the corresponding TNA price and update the standing stop-order at Schwab
  • Time = 10am
  • Calculate new stop = highest price seen in preceding 22 hours.
  • Lower new stop to 104.6% of the lowest price seen in preceding 22 hours, if greater than that
  • If I don’t currently own TZA, replace stop with the newly-calculated value.  Otherwise:
    • Discard new stop (and keep the old one) if the new value is higher
    • Sell now if highest price of last 22 hours occurred during the last hour
    • Otherwise, convert the IWM-based stop to the corresponding TZA price and update the standing stop-order at Schwab

Additional models

Currently I have two bullish models (TNA=swing and URTY=trend) and two bearish models (TZA=swing and SRTY=news).  What if I want to add a third model, such as a bullish news trade?  There are only two pairs of ETFs that offer 3× leverage on the value of the Russell 2000 basket of stocks.  However, there is also a pair of ETNs: RTLA and RTSA.  The ETF/ETN distinction doesn’t seem to matter much: there are no tax differences since I am using a retirement account, and the tail risk if Barclay’s Bank were to go belly-up doesn’t seem much different since leveraged derivatives are “side bets with the banksters” which lose all their value if the world’s financial system collapses, whether bought via an ETF or an ETN.  The trading volume of RTLA is abysmal—less than one trade per day—but does that really matter for a synthetic instrument whose shares get created on-the-fly when someone wants to buy them?

On Monday, I watched the market.  The good news is that Barclay’s (or whoever the market maker is) updates their bid/ask prices for RTLA every few seconds, even though days go by between trades.  The bad news is that the spread tends to be around 7¢, versus maybe 2¢ for TNA.

At 12:48, the offering price for RTLA was $64.65, while IWM could be had for $79.34.  By 13:32, the bid for IWM had gone down by 0.3% while the bid for RTLA went down by 0.6%, which is only 2× even though it says “3×” on the tin.  Multi-day charts show 3× performance for RTLA, but intraday performance (at least for early Monday afternoon) was only 2×.  It looks like RTLA is not suitable for news trades, which often take only a few hours from purchase to sale.

Friday, 13 July 2012

Week of 2012 JL 13

SPY rose by 0.2% this week, while my account rose by less than 0.1%.  This is my third week in a row of gains, which hasn’t happened since last October.  My loss-floor has risen to -7.0%.

New this week: in the “Daily Gains” table, the gain is now shown in green on the first day of ownership (last day still shown in red; I guess orange would be used for day-trades).

Friday’s allocations:
Daily % gain
size
Max loss
Sym  Buy Fri Mon Tue Wed Thu Fri Beg   End
 
SRTY ¹  JL06 -0.2  15  +0.1  15  +0.1  15  +0.1  15  +0.1  0  -0.7 -0.7
SRTY ²  JL11 +0.2  15  +0.5  16  +0.5  15  -0.8 -0.8
TZA  JL11 -0.2  15  -0.1  15  -0.6  14  -1.2 -1.2
SPY +8.0   +7.9   +6.9   +6.9   +6.4   +8.2
me -7.0 -6.9 -6.9 -6.8 -6.4 -7.0
floor -7.7 -6.9 -6.9 -8.9 -7.6 -7.0

Stock-trading robot

Bugfix: Last week’s NO_MODIFICATION_ALLOWED_ERR was coming from Schwab's function closeAccountSelector(), which responds to any key-event (such as the RETURN I have to send to get past Opera's stupid secure-script warning) by trying to modify the event and then maybe close the account-selector menu. Fixed using window.opera.defineMagicFunction() to override Schwab’s buggy function.  Monday's stop-update was successful, as was Monday's sale and Wednesday’s purchases.  Thursday's stop-update failed due to use of closeAccountSelector() on a different Schwab page (copied over the fix).  Thursday’s and Friday’s sales successful.

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M AMA
SRTY ¹ JL 06 13:00 JL 06 15:35 $43.55 JL 09 10:00 $44.25 $43.86 +0.1%
SRTY ² JL 11 10:00 $45.29 $45.09 JL 12 14:00 $47.00 $46.92 +0.5%
TZA JL 11 15:00 $18.65 $18.63 JL 13 12:00 $17.86 $17.85 -0.6%

SRTY ²: Fourth profitable trade in a row!  I haven’t had four winners in a row since January of 2011.

TZA: Broke my winning streak.

Friday, 6 July 2012

Week of 2012 JL 06

SPY fell by 0.5% this week, while my account rose 0.5%.  Both of these figures have returned to within 0.1% of their values as of May 11th, eight weeks ago.  My loss-floor has risen to -7.7%.

Euro economy: Greece has reported to the Troika that its citizens have stopped paying bills in Euros.  The people have lost faith in their currency, so re-drachma-tization *should* occur soon, but it seems the Hellenic Government still isn’t ready to face that music.

US economy: Friday’s Nonfarm Payroll report was bad, so the market fell (and will probably continue falling for Monday and Tuesday).  There have been a slew of negative warnings for the Q2 earnings reports.

US markets: Closed on Wednesday for Independence Day.  Tuesday was a half-day.

Friday’s allocations:
Daily % gain
size
Max loss
Sym  Buy Fri Mon Tue Wed Thu Fri Beg   End
 
TZA  JN21 -0.2  15  -0.2  0 
URTY  JN22 +1.4  17  +1.4  17  +1.4  17  +1.4  0 
TNA  JN29 +0.2  15  +0.7  16  +1.3  16  +1.3  16  +0.8  16  -1.9 +0.1
SRTY  JL06 -0.2  15  -0.7 -0.7
SPY +8.5 +8.8 +9.5 +9.0 +8.0
me -7.5 -7.0 -6.4 -6.4 -7.0
floor -9.7 -9.3 -9.2 -8.9 -7.7

TNA: Max-loss above zero!  That hasn’t happened since last November.  The stock got sold later that same day, but still — I made it to the “guaranteed” profit level.

Stock-trading robot

The big problem this week was Opera’s NO_MODIFICATION_ALLOWED_ERR, which I got during Tuesday’s stop-adjust (worked correctly on manual retry).  Same problem occurred during Friday’s stop-adjust (but the adjustment went through anyway?)  Same problem a third time prevented the SRTY purchase from going through (I used a limit order).  Clearly, Schwab has screwed around with their order-entry process YET AGAIN.  I shall have to look into that this weekend.

Another problem: Schwab failed to reset their ”volume so far today” value to zero for July 4th, so the robot did a spurious stop-update on Wednesday.

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M AMA
TNA JN 29 11:00 $52.88 $52.86 JL 06 11:00 JL 06 11:19 $55.80 $55.84 +0.8%
SRTY JL 06 13:00 JL 06 15:35 $43.55 (Not yet)

TNA: Robot failed to detect the “sell” signal at 11am.  The 10am IWM quote from Schwab was $80.60 (stockcharts.com said $80.54), then the 11am quote from Schwab was $80.54 (stockcharts said $80.44).  So the price of IWM “really” fell 10¢ during that hour but the robot saw a 6¢ drop.  My previous change to the TNA/TZA models was supposed to allow a “slop” of 0.1% price rise while still matching the sell-rule ”price must have fallen during last hour” — but I had coded it wrong so it actually required that the price had to drop by at least 0.1% (= 8¢ for IWM).  The robot tried to sell at noon, but I had already sold manually.  Bug has been fixed, but this reduces 2008..2011 TNA profits by 2.7 %-points (no effect on TZA profits).  Just dropping the “price must fall” rule would cost an additional 7.7 %-points, so I guess I’ll keep putting that off.

SRTY: Robot tried to buy at the proper time, but got the dreaded NO_MODIFICATION_ALLOWED_ERR.  I successfully used a limit-order to obtain the model’s expected price several hours later.

Gold trading

Refinement: Add a 3% hard stop in addition to the 10% trailing.  This reduces 5½ year profit from 15.4% to 15.2%, but reduces the maximum loss from 1.5% to only 0.5%.

Here is my revised model:
Using weekly indicators for IAU.
Buy signal:
  • Time = Friday at 4pm (after-hours trade).
  • MACD(14,25,9) is greater than 0.
  • MACD(14,25,9) has been less than 0 since last sale.
Sell signal:
  • Time = whenever US markets are open.
  • Current price < 90% of highest price seen since purchase or 97% of purchase price.
Here are all trades for the last 5½ years:
BuySellProfit
2007 JA 192008 MR 20+6.5%
2008 DE 122009 MR 03+1.5%
2009 MA 222009 JN 15-0.5%
2009 SE 042009 DE 17+1.5%
2010 AR 302011 AU 25+6.7%
2012 FE 242012 FE 25-0.5%

On Friday, gold jumped sharply after the NFP report, but then settled back down.  Weekly MACD is still rather negative.  A “buy” signal for this model does not seem imminent.

Saturday, 30 June 2012

Week of 2012 JN 29

SPY rose by 2.2% this week, while my account rose 1.7% and erased its last month of losses.  The loss-floor has risen to -9.7%.

Euro news: At this week’s summit, nothing of substance was definitely decided, but in the background there were several mega-purchases on stock markets.  For example, on Thursday at 3:30pm there was a single trade on the S&P 500 futures market whose notional value was $3 billion.  Somebody with a large credit line wanted to be *seen* propping up the stock market!  If the buyer used newly-printed money from a central bank, then this trade was inflationary—especially if they have to do it again next week to continue postponing the crash.  Goldman Sachs has suggested that $50 billion of inflationary stock purchases would be needed every month just to maintain the status quo.

Friday’s allocations:
Daily % gain
size
Max loss
Sym  Buy Fri Mon Tue Wed Thu Fri Beg   End
 
TZA  JN21 -0.5  15  +0.2  16  +0.0  15  -0.2  15  -0.2  15  -0.2  15 -1.3 -1.3
URTY  JN22 +0.2  15  -0.4  15  -0.3  15  +0.3  16  +0.3  16  +1.4  17 -1.3 -1.0
TNA  JN29 +0.2  15 -1.9 -1.9
SPY +6.3 +4.6 +5.2 +6.1 +5.8 +8.5
me -9.2 -9.2 -9.2 -8.8 -8.9 -7.5
floor -11.5 -11.5 -11.3 -10.2 -10.1 -9.7

Stock-trading robot

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M AMA
TZA  (Do not buy)  JN 21 14:04 $20.73 JN 27 10:00 $20.49 0.0% -0.2%
URTY JN 22 11:00 $53.93 JN 29 13:00 $59.45 +1.2% +1.4%
TNA JN 29 11:00 $52.88 $52.86 (Not yet)

TZA: Never did get a “buy” signal for this.  In my records I recorded that at JN 26 13:10, I had a hunch that this thing should be sold.  Price would have been $20.90, for a +0.1% overall profit instead of the -0.2% loss that the robot got via its “alternate sell rule”.  I am pleased that my hunches were correct twice in a row (also for TNA last week), but for now I think I’ll just paper-trade my hunches and use the robot for real-money trades.

URTY: First URTY trade is a winner!  Because URTY has such low volume, I got exactly the expected prices—but my profit was greater than expected because URTY actually does better than 3× IWM over short periods.

TNA: Normal trade in progress.  The max-loss is uncomfortably large due to the recent run-up.  The market will have to stay “up” until Wednesday before there will be a big improvement in the max-loss.

Stop updates: Monday’s update failed due to Schwab changing their login-code; apparently this was a momentary self-correcting glitch?  Thankfully, this failure prevented the robot from making an erroneous SRTY purchase due to a bug (holding URTY did not prevent SRTY purchases at 10am, only at other times).  Bug has been fixed.  The rest of the week’s stop-updates were successful.

Gold trading

I have heard that, win or lose, President Obama will have to devalue the US$ by about 20% after the election, to ensure that the USA can continue as a going concern.  Of course I should buy gold *before* the devaluation, but when?  The obvious choice is “just before the election” but maybe somewhat earlier would be better.

Here is my new model:
Using weekly indicators for IAU.
Buy signal:
  • Time = Friday at 4pm (after-hours trade).
  • MACD(14,25,9) is greater than 0.
  • MACD(14,25,9) has been less than 0 since last sale.
Sell signal:
  • Time = whenever US markets are open.
  • Current price < 90% of highest price seen since purchase.

The 10% trailing stop seems a bit much.  Previously I had determined that 5½% is enough to hang on during a parabolic uptrend, but more is needed to stay on during sideways periods between uptrends.  This model could probably generate much more profit with some additional tweaking.

Because this is a weekly model, I will run it manually rather than installing it into the robot.  This allows me to buy after Friday’s close and to use real-time trailing stops, which the robot cannot do.  I can use my automatic downloader for Yahoo quotes rather than the manual system for fetching from stockcharts.com.  Two problems:
      Splits:  In general, for purest MACD calculations, I want data that has been adjusted for splits, but not for dividends; Yahoo offers either both these adjustments or neither.  So my downloader selects “neither”, but then I had to manually adjust the data for the 10:1 split in IAU that happened in 2010.  If I start using more non-hourly models then something should be done to improve the Yahoo-quotes downloader.
      Limited archives:  Stockcharts has data for IAU going back to 1990, while Yahoo has only back to 2005.  Because weekly MACD needs about two years to ramp up to speed, this means I can backtest only to about 2007 or so.

This model trades very rarely, about once per year.  Here are all trades for the last 5½ years:
BuySellProfit
2007 JA 192008 MR 20+6.5%
2008 DE 122009 MR 03+1.5%
2009 MA 222009 DE 17+2.1%
2010 AR 302011 AU 25+6.7%
2012 FE 242012 AR 04-1.4%

This is only about 2.8% profit per year because the tranche size is only ⅟₇ of my account and IAU is not leveraged.  Maybe, if an IAU trade is in progress in late October, I’ll dump my remaining cash into it to jack up the profits (if any) from the devaluation (if it happens).

Some people think that IAU is not a good investment because it is “paper gold”.  I think paper gold is safer than physical gold, in the case where the US government confiscates all physical gold again (like in 1933).  For IAU they would just replace my gold shares with dollars; for physical gold, if I were the last recorded receiver of a nugget, they would dig up my yard looking for it.  I don’t think the fact that my yard is actually in Canada would necessarily stop them, if they are desperate enough to try a gold confiscation.

Currently, the weekly MACD for gold is quite negative.  I don’t expect a “buy” signal for at least a month.

Monday, 25 June 2012

Week of 2012 JN 22

SPY fell by 0.6% this week, while my account fell 0.3%.  The loss-floor has dropped to -11.5%, so I have lowered the bottom of the chart.

US news: On Wednesday, the Federal Reserve behaved sensibly and did not announce a new money-printing program.

Euro news: All major ratings agencies have now downgraded Spanish government debt, so by law the ECB was supposed to require more collateral from Spanish banks – but they don’t have any more!  So the law was changed to ignore the ratings agencies; banks can now deposit any random piece of paper with “I.O.U.” written on it and withdraw fresh euros from the ECB.  This is inflationary.  I predict a rising US stock market and — in a few months — food riots in some country someplace (was Algeria for QE2).

Friday’s allocations:
Daily % gain
size
Max loss
Sym  Buy Fri Mon Tue Wed Thu Fri Beg   End
 
SRTY ¹  JN13 -0.3  15 -0.3  15 -0.3  0
RWM  JN15 -0.1  15 -0.1  15 -0.4  15 -0.4  15 -0.0  15 -0.1  15 -0.7 -0.7
TNA  JN15 +0.0  15 +0.1  15 +0.8  16 +0.8  16 +0.0  15 +0.0  15 -1.3 -0.4
SRTY ²  JN21 +0.0  15 -0.1  15 -1.2 -1.2
TZA  JN21 +0.0  15 -0.5  15 -1.2 -1.3
URTY  JN22 +0.2  15 -1.3 -1.3
SPY +6.9 +7.1 +8.1 +8.0 +5.5 +6.3
me -8.9 -8.8 -8.3 -8.4 -8.7 -9.2
floor -10.8 -10.6 -10.6 -10.1 -11.8 -11.5

RWM: Non-robot trade.  I lost interest in it after URTY got its “buy” signal.  Didn’t sell on Wednesday because QE3 wasn’t announced, but the new European money-printing program amounts to the same thing.
      It was nice having this at the beginning of the week, as a hedge for TNA.  Whatever happened on the market, I owned *something* that was going up!  Going into this weekend, I own equal amounts of TZA and URTY which cancel each other out, so my account balance will not change until I decide to sell one of them.

cash: I am down to 1% cash.  If the robot were to buy another tranche of TZA on Monday, that would be using “unsettled funds” and I couldn’t sell those shares until Tuesday.  This would *probably* work out but I have decided instead to disable the “buy more” function in the robot until the TNA sale settles on Tuesday.

Stock-trading robot

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActualMAMA
TNA JN 15 15:00 $48.64 $48.65 JN 21 12:00 JN 21 12:21 $49.36 $48.82 +0.2% +0.0%
SRTY ² JN 21 14:00 $51.71 $51.75 JN 22 10:00 JN 22 10:47 $51.35 $51.49 -0.1%
TZA (Not yet) JN 21 14:04 $20.73 (Not yet)
URTY JN 22 11:00 $53.93 (Not yet)

TNA: Misread the chart and thought it was supposed to be sold at 11am (and I would have exited with +0.5% profit if I had listened to my Spidey Sense and just dumped it at 11am).  I noticed that the robot’s price-quote for 10am was way off and assumed that this was another case like May 14th where a wrong real-time quote prevented a trade.  Because I was screwing around with limit-orders, the correct sale at 12pm didn’t happen, either.  Clearly, I have lost faith in the current system and it needs repair.

SRTY ²: At 10am on Friday, the robot was supposed to update the stop for TZA and then sell SRTY, but the sale didn’t happen.  I’ve had this experience before — this time I figured out what the problem is: in shell-script, variables have global scope by default.  The code for “adjust stop price” was using the same variable-name as the main loop, so after a stop-adjustment all remaining queued operations would be skipped.  Fixed.

TZA: I guess I got override-happy.  The model did not call for a purchase because IWM’s price at 2pm was lower than the closing prices for only the preceding 29 hours, while my model calls for 32 hours of preceding lower prices for a “buy” signal.  It doesn’t make much difference: during 2008..2011 the overall TZA profit would have been only 2 %-points lower using 29 hours instead of 32 hours.  The model might yet issue a “buy” signal on Monday.  In the meantime, I have added a special rule to the robot: “If the simulated time is 2012-06-21 14:00 then buy TZA”.  This way the robot realizes that I am currently holding TZA, so it updates the stop, looks for a “sell” signal, etc.
      My manually-chosen stop was slightly too high, so the robot lowered it at the 10am adjustment on Friday.

URTY: Normal trade in progress.  First activation of the URTY model!

TRIX-based trend trades

Finally got a “buy” signal!  And it only took 436 hours of trying!  According to the back-tests, if an URTY trade isn’t going to work out, it will usually close at a loss within a week, while sucessful trades often run for over a month.

Germany has ordered the ECB not to reduce its collateral requirements, but if the ECB doesn’t print then a Spanish banking collapse may be imminent, so the ECB might well disobey orders, which could possibly cause Germany to leave the Euro, which could lead to hyperinflation in the remaining Eurozone countries.  Of course, the connection between European politics and the URTY model is tenuous at best.

MACD-based news trades

This model is currently disabled because I am holding URTY, which prevents any “buy” signals for SRTY.

PPO-based swing trades

I have changed all four rules of the form “This hour’s price > previous hour’s price” to instead use “99.9% of previous hour’s price”.  This makes the glitch less likely, but still the model and robot can disagree because the model uses top-of-hour prices while the robot uses prices from several seconds later.  A better fix would be to fetch top-of-hour prices, such as from Schwab’s “charts” module, but parsing these looks difficult — it seems they have deliberately obfuscated this data.

Sunday, 17 June 2012

Week of 2012 JN 15

SPY rose by 0.8% this week, while my account fell 0.5% to its lowest value ever.  The loss-floor has fallen to -10.8%.

World news: Crown Prince Nayef of Saudi Arabia has died.  My pet theory is that this will have a much larger effect on world affairs than the elections in Greece.  None of Nayef’s obituaries discuss his position as a kingpin among the world’s crony capitalists.  His expected replacement, Prince Salman, is a very different man.

Euro news: The lying is nearing a crescendo.  The BBC reports that Spain “was given” a bailout.  Oh yeah?  They got *promises* of a bailout.  You can’t eat promises.

US news: Next Wednesday, the Federal Reserve will announce its policy for the next two months.  Far too many people have written that it is “almost certain” that they will announce a new money-printing program (QE3).  I think this is absurd.  Printing money now will cause a spike in the price of food, which could start another Arab Spring, which Saudi Arabia cannot afford during their line-of-succession difficulties.  Hopefully the Fed will put this off until August, which will cause large numbers of traders to be sorely disappointed next week.

Friday’s allocations:
Daily % gain
size
Max loss
Sym  Buy Fri Mon Tue Wed Thu Fri Beg   End
 
SRTY ¹  JN12 -0.1 15  -0.1  15 -0.1  15 -0.1  0 -1.0 -1.0
SRTY ²  JN13 +0.1  15 -0.3 15  -0.3  15 -1.1 -1.1
RWM  JN15 -0.1  15 -0.7 -0.7
TNA  JN15 +0.0  15 -1.3 -1.3
SPY +6.1 +4.7 +5.9 +5.2 +6.4 +6.9
me -8.4 -8.4 -8.5 -8.4 -8.8 -8.9
floor -8.4 -8.4 -8.5 -9.7 -8.8 -10.8

New this week: the daily-gains table no longer has a “Final Gain” column.  Instead, when a security is sold, its daily gain is red for one day and then freezes for three days until the trade settles and the size goes to 0%.

RWM: Non-robot trade.  Obviously the market is going down, so I might as well bet against it.  Sell if QE3 is announced, or hold until the crash (with 5% trailing stop to catch the bottom).  RWM is a 1× bear, while TNA is 3× bull, so for now I am net 30% long.  My guess is that the market will be down on Monday, up on Tuesday, stable on Wednesday if “Operation Twist 2” is announced, then begin its decline.

Stock-trading robot

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActualMAMA
SRTY ¹ JN 12 11:00 JN 12 11:06 $55.49 $54.77 JN 13 14:00 JN 13 14:12 $54.27 $54.34 -0.3% -0.1%
SRTY ² JN 13 15:00 $54.51 $54.41 JN 14 14:00 $53.38 $53.42 -0.3%
TNA JN 15 15:00 $48.64 $48.65 (Not yet)

SRTY ¹: Tuesday's buy-order did not go through because Schwab reformatted their website again.  Entered manually.  Sell-order didn't work either, so entered manually as well.  Adjusted the robot code.

SRTY ²: Wednesday's buy-order went through, but not the sell-stop order.  Entered manually.  More robot code adjustments.

TNA: Robot is now working properly again.

Surfing the Oscillations

The robot has lost money for every month of its existence.  MarketSniper explains why: in their desperation to avoid the next crash, the central banksters are now intervening in the markets almost continuously, breaking up even the hourly patterns that my robot is looking for.  We’ve seen this script before.  Remember “Baghdad Bob” announcing that the Yankees have been defeated, while US tanks roll down the street behind him?  Increasingly I see the words “end game” being used to describe the Euro situation (and by extension the US situation).  The game actually ended about two years ago.  Wile E. Coyote is off the cliff, hovering in thin air, refusing to admit that he is actually falling.  Eventually he will hit the ground and the illusion will shatter.  Hopefully my robot will catch the crash and make lots of money, but as of yet there is no evidence that it will actually work.

Last year, the TNA and TZA models would have lost money in the first half, then made it all back and more in the second half.  We shall see how 2012 turns out.