Sunday, 19 August 2012

Week of 2012 AU 17

SPY rose by 1.1% this week, to its highest weekly close since May 2008!  I have raised the top of the chart to +14%.  My account fell 0.4% to just above its lowest value ever.  The loss-floor is now -9.6%.

Participant mood: The bears are howling in pain!  It looks like the markets will be rocketing to the moon from now until November.  This is the “capitulation”, which is followed by the “blow-off top” and then the “crash”.  But November is just a wild guess; David Banister predicts that it will end by early September at the latest.  Really, the markets will keep going up until some piece of news spooks the herd.  What will it be?
      Volume on the New York Stock Exchange is the lowest it’s been in ten years.  There was a large drop (around 20%) that occurred suddenly when Knight Capital went out of business, as if a whole bunch of HFT computers were snuffed out.  Falling volume with rising prices is usually a pre-crash sign, but there is no telling how long this uptrend might continue before it turns.

US news: The Obama Administration is considering a release of oil from their Strategic Reserve.  Last year, they announced a release on June 23.  The market jumped for two weeks, then wobbled for three weeks, then plummeted and did not return to its pre-announcement price for eight more weeks.  Of course, there was also a debt-ceiling debate at the time, and the official reason for the release was Arab Spring in Libya; neither of these seem to be happening this year.  Something awful will have to happen in the Middle East (presumably involving Iran) to justify a release from the reserves.  The stock market generally falls at the start of a war due to uncertainty.  I still think that Obama wants the market to crash before the election, because low stock prices hurt Republicans more than they hurt Democrats (and nothing else matters to those clowns).  But Obama is a weak president and his government often seems to disobey him, so who knows what may happen?

Euro news: Chancellor Merkel has returned from vacation and put her foot down regarding the illegal money-printing that was going on at the national banks.  The Euro has been falling, which usually causes US stocks to follow suit, but not this time.

Friday’s allocations:
Daily % gain
size
│Max loss
Sym  Buy │ Fri Mon Tue Wed Thu Fri │ Beg   End
 
SRTY  AU10 │ -0.1  15  +0.1  15  +0.1  15  +0.1  16  +0.1  0  │ -0.4 -0.3
TZA  AU13 │ -0.4  15  -0.3  15  -0.6  15  -0.7  15  -0.7  15  │ -0.7 -0.7
IAU  AU14 │ -0.0  13  +0.0  13  +0.1  14  +0.1  14  │ -0.4 -0.4
SPY │ +12.2     +12.3     +12.2     +12.3     +13.2     +13.3 │
me │ -8.7 -8.9 -8.8 -9.1 -9.1 -9.1 │
floor │ -9.0 -9.2 -9.6 -9.6 -9.6 -9.6 │

size: On Wednesday, the size of my SRTY position increased from 15% to 16% of account, even though the position had already been sold by that point, because the denominator (total size of my account) dropped from 8.8% below-start-of-year to 9.1% below.
      On Thursday, the size of my IAU position increased from 13% of account to 14%, even though the total size of my account did not change significantly, because the price of gold went up a little and the position was already so close to 14% in size.

Stock-trading robot

HostMDS:  Timeout failures on quote-fetches continued until Thursday, when things returned to normal.  Presumably one of HostMDS’s other customers complained and got them to fix whatever it was.  I didn’t put in any effort this week towards finding a replacement ISP.

Schwab: Although Schwab and OptionsXpress are owned by the same holding company, I still can’t transfer my account from one to the other.  They say the legally-approved thing for me to do is open an RSP and then slowly transfer money from the IRA to the RSP, to minimize the tax bite.  I don’t want to do that.  I have begun the process of opening a TFSA account at OptionsXpress. The money will get taxed when it leaves the IRA but there is no tax credit for TFSA deposits.  Profits (if any) *should* be untaxed while they remain inside the TFSA, but the USA doesn’t recognize that kind of retirement account so the legalities are still unclear.  I have to open the account (which will take several weeks) before I can find out whether they will allow me to use their API, without which there will turn out to have been no reason to have opened the account.  Catch-22!

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M  A  M  A 
SRTY AU 10 11:00 AU 10 12:06 $43.75 AU 13 14:00 $44.10 $44.08 +0.1%
TZA AU 13 11:00 AU 13 11:01 $17.99 AU 14 10:00 AU 16 11:19 $17.15 $17.09 -0.7%

SRTY: Another winning trade for the SRTY model!  The win:loss ratio is now 8:11, with a gain of +1.3% over four months.  Average return for this model is supposed to be 2.5% per quarter (but only 1.25% average for the second quarters), so even SRTY is doing poorly — still, it is eking out a profit even under these adverse market conditions.

TZA: Was bought one minute late because HostMDS was still running so slow; robot got the expected top-of-hour price anyway.  On Tuesday, the robot thought it had stopped out, but actually hadn't because the TZA stops are slightly looser than the IWM calculations due to leverage.  I added a fake high price to Monday's data archive so robot would know that I still owned this thing.  On Wednesday, price got down to $17.20, with my stop at $17.10.  Finally stopped out for real on Thursday.

Gold trading

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M  A  M  A 
IAU AU 03 16:00 AU 14 09:30 $15.61 $15.57 (Not yet)

Limit order finally filled on Tuesday, with a gap-down so I got price improvement.  By then the 50-day moving average had risen to my limit price, so gold bounced there and has been rising ever since.  But the price of gold usually moves very slowly, so my account has gained only 0.1% so far on this trade.

Surfing the oscillations

Last week I predicted that IWM's price would fall back to the red channel line, which it did on Monday.  Then I said it would either start heading down to the lower red channel line or it would bounce and “begin a period of serious uptrend”.  It seems the latter is what has happened.  This may be the “final blow-off top before the crash”.  It could go on for months, or it could end next week.

The market is nearing “overbought” levels, so I am expecting a downdraft for next week.  If it is sharp enough, my URTY model will trigger and I will “ride the bull” for awhile.

PPO-based swing trades

Bull swing (TNA)Bear swing (TZA)
Stop adjust×1.000×1.003×1.000×0.999
Win:loss29:1529:1521:1321:13
Profit50.73%52.13%66.33%66.37%
Avg.Risk1.27%1.13%0.48%0.46%

This week my TZA position had multiple near-death experiences before finally kicking the bucket, with a full loss of my initial maximum risk.  I thought that maybe my stops should be slightly looser, but new tests indicate that actually they should be tighter.  The table at right shows results for 2008..2011.  These results may be somewhat bogus.  Tightening my TNA stops by 0.3% seems to produce noticable improvements in profit and risk, with no effect on which trades are winners or loses.

The results for TZA are useless.  The profit and risk improvements are insignificant.  It is unrealistic for me to tighten stops by 0.1%, because other slop in the system often causes reality to differ from my model by more than that.  Maybe someday I can get proper quotes from OptionsXpress and set proper stops that don’t involve guesswork multiplication — but not today.

Next approach: when prices get *close* to my stop and then bounce, then sell on the next upswing because things will be going bad soon.  What counts as “close”?  For TZA I tried using ¼ of STDDEV(7) since I have that number lying around and it scales based on market volatility.  By this definition, TZA had three near-death experiences this year (late April, early May, and mid-August).  It looks like all three of them could have been helped, but there aren’t enough examples to be sure.  Oddly enough, backtesting shows no similar experiences in prior years, so clearly something has changed in this market.

Experimental rule: If prices get close to the stop and then bounce, then sell the shares manually when the retrace seems to be over (e.g., after the first hour when price moves against me by more than a trivial amount).

Sunday, 12 August 2012

Week of 2012 AU 10

SPY rose by 1.2% this week, returning to its high of the year back on MR 30.  My account fell 0.4% to its third-lowest value of the year.  The loss-floor is now -9.0%.

Bankster activity: For the first time since 2008, the US Fed has started doing “repos” again.  This is where they print up some money and give it to crony banks in exchange for worthless IOU’s, because the alternative would be that “too big to fail” banks would fail.  At least $600 million has been printed during these small-scale tests over the last week or so.
      On Wednesday, it came out that the Bank of Greece printed €800 million (with tacit approval from the ECB, despite the blatant Maastricht treaty violation).  Presumably this was done because the alternative would have been a complete collapse of Greek government.  It seems that Greece will need to print €3.2 billion of the common currency over the next month, which means the wealth of all Europeans is being secretly diluted to support those banksters who loaned money years ago to other banksters, who had borrowed in the name of the people of Greece.
      On Thursday, it was reported that a US appeals court has affirmed a lower court’s ruling that when a futures brokerage pledges its customers’ money to a TBTF bank to cover the brokerage’s own debts, that is not “fraud” and the bank need not return the stolen money to the retail customers.  It seems the USA has only one law right now: the TBTF banks are always right — this law supercedes all others.  It is unclear whether this latest ruling applies only to futures accounts.  I have a retirement account.  There are many laws limiting what a brokerage can do with retirement money, but perhaps the “one law” supercedes all of those.
      Mark Carney, head of the Bank of Canada and also of the world Financial Stability Board, has now officially refused the offer to become head of the Bank of England as well.  He says he will “blow the whistle” on banks that fail to adhere to the new capital requirements and believes that Canadian banks will meet these requirements years before everyone else.  It sounds to me like he is threatening any world banksters who fail to join his team — will his next job be grand nagus?

The world of sports: This weekend, the Olympic Games will end.  Many stock traders have been enjoying them.  There will be a let-down next week because no more enjoyment of that type will be available for several years.  Historically, the stock market tends to fall during the week after the games.

Friday’s allocations:
Daily % gain
size
│Max loss
Sym  Buy │ Fri Mon Tue Wed Thu Fri │ Beg   End
 
TNA  AU06 │ -0.1  15  +0.2  31  -0.0  31  +0.4  31  -0.3  30  │ -1.7 -0.3
SRTY  AU10 │ -0.1  15  │ -0.4 -0.4
SPY │ +11.0     +11.3     +11.8     +11.9     +12.0     +12.2 │
me │ -8.3 -8.4 -8.1 -8.3 -7.9 -8.7 │
floor │ -8.3 -10.0 -12.1 -10.6 -9.6 -9.0 │

floor: The loss-floor briefly went below -12% on Tuesday, but picked up again by the end of the week so I didn’t have to lower the bottom on the weekly-progress chart above.

Stock-trading robot

Quote-fetch system:  Worked fine until Friday.  The 11am, 12pm, and 1pm fetches all timed out after 60 seconds, while the 2pm, 3pm, and 4pm fetches barely succeeded in slightly less than 60 seconds.  Problem doesn’t seem to be at Schwab’s end, while my ISP does not seem otherwise slow.  I had to go out on Friday, so it was a bad day for the robot not to be working.  On Saturday, test quote fetches continued to be problematic, until I ran Opera interactively on the server; after that things seemed to work again (but we’ll have to see next week).  My ISP now says that I am allowed 200 MB of RAM for my processes, but I don’t remember what the old number was (or if it was different).
      There seems little point in complaining to my ISP about this; they’ve already said they think I should upgrade to a virtual private server.  I think it is wrong of them to remove features (such as last year’s ability to recompile my own programs, and perhaps now the ability to run programs larger than 200 MB) from a service that I have already paid for in advance — they should refuse to renew if they don’t want to continue their business on current terms.  My lease with them expires next month; perhaps I should find a new home for my robot.
      Further research has suggested that it is illegal for me to move my account from Schwab to Interactive Brokers — or to anyone else.  Because I am not a US resident, no broker is permitted to open a new IRA account for me and so my money is stuck at Schwab forever.  However, last year Schwab bought OptionsXpress, which offers an API to their trading system.  I should call Schwab to find out whether moving from Schwab to OptionsXpress is permissible for non-resident IRA’s.

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M  A  M  A 
TNA AU 06 11:00 $52.96 $53.00 AU 10 12:00 AU 10 11:05 $53.16 $53.09 -0.3%
AU 07 11:00 $54.27 $54.26
SRTY AU 10 11:00 AU 10 12:06 $43.75 (Not yet)

TNA: Yet another loss.  There was a sudden downdraft on Friday just after 11am, causing a stop-out with slippage.  Without that event, the rest of the day would have been okay and I would still be holding TNA, which might very well go up early next week.  But it seems sudden downdrafts often presage more sustained downtrends, so it’s quite possible that the loss would have ended up being just as large but postponed into next week.

SRTY: The quote-failure at 11am prevented robot purchase, but I didn’t notice until noon.  I entered the order manually at “market price” and then left the house.  It just so happened that I got the exact price that the model had called for an hour earlier.

Surfing the oscillations

The market zoomed up to the channel line in the first half-hour of Monday, continued rising until 1pm, then fell back to the channel line for the close.  On Tuesday it gapped up and spent the rest of the week doing a “bull flag”.  I think it will drop back to the upper channel line next week — but after that it might fall back into the channel (and start heading towards the lower line) or perhaps it could bounce off the upper line and then begin a period of serious uptrend (presumably fuelled by bankster money-printing since the fundamentals are all very bad these days).  I’m leaning bearish, but there’s just no way to know.

The market remains stuck in the same ±3% range that it’s been in for two months now.  I haven't gained or lost any significant money during this time.  My understanding is that many traders more seasoned than I have had similar experiences.  This has not been a good year for trading!  Just my luck.

Gold trading

I put in a limit-order to try to get last Friday’s price, but gold never got that low this week.  Gold has closed higher for six days in a row.  The last time that happened was early June, after which gold spent the next three days going straight down and giving up all six days’ gains and more.  I will give my limit-order another week.

David Banister suggests that gold should be bought when it reaches $1630/oz, which happened for a moment Friday morning (followed by falling prices for the rest of the day).  Sy Harding says his indicators are hovering just below a “buy” signal for gold and he is waiting for $1645/oz (the 30-week moving average).  I think this means that neither of them has bought yet, and I haven’t either.

MACD-based news trades

SRTY has been my best-performing model this year, yielding 1.2% of profit over four months with a win:loss ratio of 7:11.  I could jack this up by e.g. buying two tranches instead of one, but that would tie up a lot of money and I don’t have much left.  Another approach would be to buy IWM puts instead of SRTY shares.  They require much less capital so I could buy more (potentially a lot more) of them.  However, this would require requesting “Options level 1” from Schwab, which I became eligible for as of Christmas 2011 (but I never sent in the request).

Friday, 3 August 2012

Week of 2012 AU 03

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

Tuesday: At 3:59:57pm there was a single trade on /ES for 150,000 futures contracts (notional = $10 billion).  In June there had been a huge buy and then the market went up; this time apparently a huge sell, but the market just sagged a little without a major drop.

Wednesday: Ben Bernanke of the US Fed did not announce any quantitative easing.  The market fell.

Thursday: Mario Draghi of the ECB did not announce any quantitative easing.  Immediately afterward, at 7:30am EDT, another 65,000 futures contracts on got sold on /ES (= $4.4 billion notional).  The market fell.

Friday: Short squeeze!  Europe started rising, then the US govt announced the non-farm payroll: 165,000 new jobs (of which 429,000 were fake), then US markets opened and continued the rise.  In accordance with tradition, the NFP will be treated as the “cause” of a market action that began hours earlier.

Friday’s allocations:
Daily % gain
size
│Max loss
Sym  Buy │ Fri Mon Tue Wed Thu Fri │ Beg   End
 
SRTY  AU01 │ +0.4  15  +0.8  16  +0.8  16  │ -1.2 -1.0
TZA  AU02 │ +0.0  15  -1.1  14  │ -1.6 -1.4
SPY │ +10.5     +10.5     +9.7     +9.6     +8.9     +11.0 │
me │ -7.9 -7.9 -7.9 -7.5 -7.1 -8.3 │
floor │ -7.9 -7.9 -7.9 -9.1 -8.7 -8.3 │

Stock-trading robot

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M  A  M  A 
SRTY AU 01 14:00 $47.54 AU 02 14:00 $50.15 $50.16 +0.8%
TZA AU 02 10:00 $19.71 $50.10 AU 03 12:00 $18.15 $18.12 -1.1%

SRTY: Yay!  Biggest win since June.

TZA: Rats!  Biggest loss since May.

Quote fetch&archive system:  The daily replacement of Schwab quotes with Barchart quotes worked correctly Monday through Thursday, but once again failed Friday because Barchart insisted on providing two days’ worth of data when I asked for one.  Maybe this is a general Friday problem?  Added code to the program to delete unrequested data from Barchart.
      On Tuesday, Barchart said that the 10am quote for IWM was $79.12, while Schwab had said $79.27 which is 0.16% higher, so my “allow 0.1% slop” rule wouldn't have been enough.  Schwab's quote was from 10:00:10am and the market moved a lot during those ten seconds.

Interactive Brokers:  I haven’t yet looked into how difficult it is to move an IRA account when you don’t live in the States anymore, but I did find out that InteractiveBrokers is indeed a “clearing broker” (meaning that they hold your positions in their own name, rather than using a 4th party).  Their API seems to do what I need: at 12:00:03pm, I want to get the OHLV candlestick values for 11am-12pm, not the current real-time quote.  Also their API allows robots to enter trailing-stop orders (unlike Schwab).

Surfing the oscillations

This week, the market fell for four days, then made almost all of it back on Friday.  It did not fall to the bottom of the channel, instead making something of a “double bottom”.  Also, it did not rise all the way to the top of the channel today.

Since the market generally continues in the same direction for the Monday and Tuesday following an NFP announcement, I expect that that IWM will hover near the top of its channel for the start of next week.  Alternative: gap up out of the channel, which would make sense if the intent is for SPY to return to its yearly high in March before crashing after the Olympics.  Only 1.5% more to go for new highs this year!

Gold trading

A wild week!  On Monday and Tuesday, it seemed that this week would end with a “buy” signal for IAU.  On Wednesday and Thursday, it seemed that this week would *not* end with a “buy”.  As of Friday’s close, the weekly MACD histogram is +0.001, which is actually a minimal “buy” signal.  But I didn’t buy.  Let’s see how next week starts out.

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.