Saturday, 20 July 2013

Week of 2013 JL 19

IWM rose by 2.0% this week, to its highest value ever.  My account rose 0.7%.  The loss-floor has dropped to -9.3%.

End of week allocations:
Daily % gain
size
Max loss
Sym  Buy  Fri  Mon  Tue  Wed  Thu  Fri Beg   End
 
FNSR +0.1  10  +0.0  10  +0.0  10  -0.0  10  +0.1  10  -1.7 -1.5
UWM +0.1  10  -0.0  10  +0.1  10  +0.2  10  +0.2  10  -0.9 -0.6
URTY +0.1  10  -0.0  10  +0.1  10  +0.3  10  +0.3  10  -1.5 -1.3
IWM +24.4     +25.5     +24.9     +25.4     +26.2     +26.4    
me -6.1 -5.8 -6.0 -5.8 -5.6 -5.4
floor -6.1 -10.1 -9.8 -9.7 -9.5 -9.3

Double-TRIX trading model

The TLINE indicator doesn’t seem to work well (the longest steepest trendlines should be the most reliable ones, but they aren’t), so I have removed it.  Meanwhile, I still need something to avoid horrible results for ATML in the years 2000 and 2004.  Instead, I have added two new tests: “SMA(q)” and “Retest sale”.

Buy signal:
When all are true:
  • TRIX(q) > its EMA(2)
  • Either TRIX(q) < 0 OR TRIX(s) > its EMA(2)
  • close ≤ SMA(q)
  • Low > stop
For a daily trade, the signal is given after the daily close and so the purchase is at tomorrow’s opening price.  For hourly, signals are given on the hour 11am‥3pm and the purchase is immediate.
Sell signal:
When all are true:
  • TRIX(q) < its EMA(2)
  • TRIX(s) < its EMA(2)
For a daily trade, the signal is given after the daily close and so the sale is at tomorrow’s opening price.  For hourly, signals are given on the hour 11am‥3pm and the sale is immediate.
Retest sale:
When exactly w periods have passed after a purchase, if close < m times the purchase price, then sell (next day for daily, immediately for hourly).
Stop-price:
If close > SMA(s):
  • stop = CHANDELIER(c⁺,a⁺)
Otherwise:
  • stop = CHANDELIER(c⁻,a⁻)
For daily or hourly trades, the stop is recalculated once per day, after market close, and is used as the stop-price for the following day.  At any time, if low < stop, then we recognize that the shares were sold and the trade is over.

Here are the revised parameter values for the first four trades:
ATML
(daily)
FNSR
(daily)
IWM
(daily)
IWM
(hourly)
Trade ticker ATML FNSR UWM (2×) URTY (3×)
TRIX(q) 3 3 12 75
TRIX(s) 17 17 51 429
SMA(q) 9 1 3 1
SMA(s) 240 270 130 580
CHANDELIER(c⁺,a⁺) 27, 4.9 25, 6.0 32, 3.4 360, 12.9
CHANDELIER(c⁻,a⁻) 21, 4.2 22, 3.8 23, 2.7 110, 12.0
RETEST(w,m) 4, 1.01 3, 0.99 3, 1.00 21, 0.99

For the new RETEST function, w is always around 3 — maybe the 4 value for ATML is an artifact?  The m value is always around 1.00 — maybe it should always be exactly 1.00?

The new SMA(q) function is probably wrong.  Because it says not to buy if price is too high, that makes the system susceptible to missing out on run-ups if price rises too soon and then never falls below the SMA for weeks on end.  For FNSR it seems worse than useless.  For IWM, it nearly doubles the expected return at the daily level, but is useless at the hourly level???  This probably needs more work.

Here are some figures for ATML, showing simulated results for the last 22 years.  The “Hold” figure shows the result for using all my money to hold ATML all year, while “Trade” shows the effect of the double-TRIX trading strategy (using only 10% of my money).  Numbers shown with red background would have been disappointing:
YearHoldTrade   YearHoldTrade
1992+87%-1.0% 2003+160%+14.4%
1993+111%+4.4% 2004-35%-3.0%
1994+94%+2.7% 2005-21%+5.8%
1995+34%+2.1% 2006+96%+4.5%
1996+49%+2.5% 2007-27%-0.4%
1997-45%-0.8% 2008-34%+0.5%
1998-17%+4.1% 2009+50%+2.6%
1999+286%+7.1% 2010+183%+0.4%
2000-21%-0.1% 2011-34%-2.4%
2001-33%+3.0% 2012-2%+1.9%
2002-71%+9.6% 2013*+12%-0.4%
There are three kinds of disappointments: ⑴ ATML makes lots of money, but I get less than half of it; ⑵ ATML makes money but I lose that year [1992, 2013]; and ⑶ I lose 3.0% or more of my money in one year [2004].  For 2013, only the data for the first six months is shown.

Stock-trading robot

So far, so good!  This week the robot correctly updated its stop on URTY each day, and correctly decided not to sell anything.  Next week, I will have it automatically update the stops on FNSR and UWM (which were done manually this week) and it should also be ready to sell those tickers automatically when the trading model says to.

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M  A  M  A 
FNSR MA 29 09:30 JL 15 09:30 $12.81 $18.48 (Not yet)
UWM JL 05 09:30 JL 15 09:30 $63.31 $67.95 (Not yet)
URTY JL 01 11:00 JL 15 09:30 $55.03 $63.70 (Not yet)

For FNSR, the opening price for JL 15 was $18.15, but I got a much worse price than that, perhaps because my purchase was not a round multiple of 100 shares.  This suggests that FNSR might not be a good choice for trading because I won’t actually get the prices that the simulator predicts.

For UWM, the purchase date should have been JL 05, not JL 03 as shown last week.

Monday, 15 July 2013

Week of 2013 JL 12

IWM rose by 3.6% this week, to its highest value ever.  My account was unchanged.  The loss-floor remains at -6.1%.

No trades for me this week.

End of week allocations:
Daily % gain
size
Max loss
Sym  Buy  Fri  Mon  Tue  Wed  Thu  Fri Beg   End
 
IWM +20.8     +21.3     +22.4     +22.7     +24.2     +24.4    
me -6.1 -6.1 -6.1 -6.1 -6.1 -6.1
floor -6.1 -6.1 -6.1 -6.1 -6.1 -6.1

New double-TRIX trading model

There have been no changes to the robot’s trading models for eleven months (since “Week of 2012 AU 17”).  Since that time, there have been about 60 trades but the value of my account has gone approximately nowhere.  On June 24th, I went to a programmers’ meet-up and showed them some of the robot’s code.  They were flabbergasted that I have continued to work on this thing for 2½ years even though it has never made any money.  What kind of crazy crank must I be to do such a thing???  I decided to create a new model for next month’s meetup, perhaps one that would actually work for a change!

Buy signal:
When all are true:
  • TRIX(q) > its EMA(2)
  • Either TRIX(q) < 0 OR TRIX(s) > its EMA(2)
  • Low > stop
  • There is no trendline from TLINE(t,slopelimit,peakdist,slop) or there have been fewer than numsubpeaks under it.
For a daily trade, the signal is given after the daily close and so the purchase is at tomorrow’s opening price.  For hourly, signals are given on the hour 11am‥3pm and the purchase is immediate.
Sell signal:
When all are true:
  • TRIX(q) < its EMA(2)
  • TRIX(s) < its EMA(2)
For a daily trade, the signal is given after the daily close and so the sale is at tomorrow’s opening price.  For hourly, signals are given on the hour 11am‥3pm and the sale is immediate.
Stop-price:
If close > SMA(m):
  • stop = CHANDELIER(c⁺,a⁺)
Otherwise:
  • stop = CHANDELIER(c⁻,a⁻)
For daily or hourly trades, the stop is recalculated once per day, after market close, and is used as the stop-price for the following day.  At any time, if low < stop, then we recognize that the shares were sold and the trade is over.

CHANDELIER(c,a) is a standard technical indicator that I haven’t used before.  We call DONCHIAN(c,high) to find the ceiling, then “hang” our stop below that by subtracting a times ATR(c), the Average True Range for the period.

TLINE(t,slopelimit,peakdist,slop) is a new technical indicator I made up that is supposed to be a simplistic “trendline” generator.  We process each period as follows:
  • If there is a trendline and high is below it, the trend continues.  If trend÷highslop+1 then this is a possible subpeak; if more than peakdist periods have passed since the previous subpeak and/or the trendline-defining peak₁ or peak₂, then increment the number of subpeaks seen for this trend.
  • If high > peak₁, this is our new high-point.  It replaces peak₁ and there is no trendline.
  • Otherwise, we have a new peak₂.  Compute its slope (on a logarhythmic chart) as peak₂÷peak₁ where i is the number of periods that have elapsed since peak₁.
    • If this “ith root” ≥ slopelimit, the trendline is not steep enough to be usable so high becomes our new peak₁ and there is no trendline.
    • Otherwise, we rescan from peak₁ to count up the subpeaks for the new trendline.
  • At the end of each period, if peak₁ was more than t periods ago then it is too old, so replace peak₁ with peak₂ and rescan for a new peak₂ and possible subpeaks.

Here are the parameter values for the first four trades:
ATML
(daily)
FNSR
(daily)
IWM
(daily)
IWM
(hourly)
TRIX(q) 3 3 12 75
TRIX(s) 17 17 51 430
SMA(m) 230 260 130 580
CHANDELIER(c⁺,a⁺) 27, 5.0 25, 6.0 32, 3.7 290, 12.9
CHANDELIER(c⁻,a⁻) 23, 3.8 22, 3.8 23, 2.6 110, 12.1
TLINE(t,slopelimit,peakdist,slop) 23, 0.998, 2, 0.08 35, 0.995, 2, 0.08 56, 0.999, 2, 0.07 210, 0.9999, 3, 0.09
numsubpeaks 1 1 1 2
Trade ticker ATML FNSR UWM (2×) URTY (3×)

Currently, ATML does not have a “buy” signal but the other three do.  Should I buy now, or wait for the next “sell” and then buy on the following “buy” signal?  Usually I would wait, but Tim Knight wrote that he thinks the market is going much higher this summer, so I told my broker to buy FNSR, UWM, and URTY at Monday’s open.

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M  A  M  A 
FNSR MA 29 09:30 JL 15 09:30 $12.81 ??? (Not yet)
UWM JL 03 09:30 JL 15 09:30 $61.24 ??? (Not yet)
URTY JL 01 11:00 JL 15 09:30 $55.03 ??? (Not yet)

Week of 2013 JL 05

IWM rose by 3.3% this week, while my account fell 0.4% to its lowest value ever.  The loss-floor is now -6.1%.

US markets were closed on Thursday for Independence Day.

End of week allocations:
Daily % gain
size
Max loss
Sym  Buy  Fri  Mon  Tue  Wed  Thu  Fri Beg   End
 
SRTY  JL03 -0.4  20  -0.4  20  -0.8 -0.8
IWM +17.5     +19.4     +18.8     +19.1         +20.8    
me -5.7 -5.7 -5.7 -6.1 -6.1
floor -5.7 -5.7 -5.7 -6.1 -6.1

Stock-trading robot

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M  A  M  A 
SRTY (Do not buy) JL 03 12:00 $19.22 JL 03 13:00 $18.89 -0.4%

SRTY: I failed to notice IWM’s dividend payment Tuesday morning, which caused the robot to make an incorrect purchase Wednesday afternoon.  Fixed.

Week of 2013 JN 28

Week of 2013 JN 28

IWM rose by 1.2% this week, while my account fell 0.7% to its lowest value ever.  The loss-floor is now -5.7%.

End of week allocations:
Daily % gain
size
Max loss
Sym  Buy  Fri  Mon  Tue  Wed  Thu  Fri Beg   End
 
SRTY  JN24 -0.3  20  -0.8  19  -0.8  19  -0.8  19  -0.8  0  -1.6 -1.0
IWM +16.3     +15.6     +15.9     +16.4     +18.2     +17.5    
me -5.0 -5.3 -5.7 -5.7 -5.7 -5.7
floor -5.0 -6.1 -5.7 -5.7 -5.7 -5.7

Stock-trading robot

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M  A  M  A 
SRTY JN 24 10:00 $21.88 $21.87 JN 25 15:00 $21.04 -0.7% -0.8%

SRTY: Yet another loss.

Week of 2013 JN 21

IWM fell by 1.9% this week, while my account rose 0.3%.  The loss-floor is now -5.0%.

End of week allocations:
Daily % gain
size
Max loss
Sym  Buy  Fri  Mon  Tue  Wed  Thu  Fri Beg   End
 
SRTY  JN20 +0.3  20  +0.3  20  -1.6 -1.6
IWM +18.4     +19.2     +20.6     +19.1     +15.9     +16.3    
me -5.3 -5.3 -5.3 -5.3 -5.0 -5.0
floor -5.3 -5.3 -5.3 -5.3 -6.9 -5.0

Stock-trading robot

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M  A  M  A 
SRTY JN 20 11:00 $20.55 JN 21 10:00 $20.94 +0.38% +0.33%

SRTY: A gain, for a change!  But not much.

Week of 2013 JN 14

IWM fell by 0.6% this week, while my account fell 1.9%.  The loss-floor is now -5.3%.

End of week allocations:
Daily % gain
size
Max loss
Sym  Buy  Fri  Mon  Tue  Wed  Thu  Fri Beg   End
 
TNA  JN10 +0.2  40  -1.1  39  -1.6  38  -1.6  38  -1.6  38  -1.7 -2.0
SRTY ¹  JN12 +0.2  20  -0.0  20  -0.0  20  -1.0 -0.8
SRTY ²  JN13 -0.3  20  -0.3  20  -0.4 -0.4
IWM +19.0     +19.7     +18.4     +17.2     +19.3     +18.4    
me -3.4 -3.2 -4.5 -4.9 -5.3 -5.3
floor -3.4 -6.7 -6.7 -6.0 -5.3 -5.3

Stock-trading robot

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M  A  M  A 
TNA JN 10 11:00 $49.51 $49.64 JN 12 13:00 JN 12 12:00 $47.08 $47.60 -2.0% -1.6%
JN 10 12:00 $49.71 $49.72
SRTY ¹ JN 12 12:00 $20.21 $20.22 JN 13 11:00 $20.24 +0.06% -0.01%
SRTY ² JN 13 14:00 $19.81 $19.80 JN 13 15:00 $19.58 $19.57 -0.24% -0.25%

TNA: Bought a tranche, then bought another tranche an hour later because the rebuy-rule immediately applied.  Maybe I should require a delay before rebuying?
      The model says I stopped out, but actually this was a robot-sale due to a slight wobble in price-quotes.

SRTY: Two more losses.  The SRTY² trade was especially silly.  This model seems poorly tuned for the market we’re in these days.

Week of 2013 JN 07

IWM rose by 0.5% this week, while my account fell 0.9%.  The loss-floor is now -3.4%.

End of week allocations:
Daily % gain
size
Max loss
Sym  Buy  Fri  Mon  Tue  Wed  Thu  Fri Beg   End
 
URTY  MA23 +0.2  19  +1.2  40  +0.0  39  -1.3  38  -1.3  38  -1.3  38  -0.7 -1.4
TZA  JN03 -0.7  18  -1.0  18  -1.0  18  -1.0  18  -1.0  18  -1.0 -1.0
SRTY  JN05 -0.0  20  -0.5  19  -0.5  19  -1.6 -1.6
IWM +18.5     +19.6     +18.4     +16.8     +18.1     +19.0    
me -0.5 -0.1 -1.6 -3.0 -3.4 -3.4
floor -1.3 -2.9 -3.0 -4.5 -3.4 -3.4

Stock-trading robot

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActual M  A  M  A 
URTY MA 23 12:00 $108.27 $108.22 JN 05 12:00 $104.84 -1.3%
JN 03 15:00 JN 03 14:00 $108.76 $108.54
TZA JN 03 12:00 $32.11 $32.10 JN 05 10:00 JN 05 09:36 $30.56 $30.44 -1.0%
SRTY JN 05 12:00 $20.62 $20.76 JN 06 10:00 $20.31 $20.29 -0.43% -0.46%

URTY: Rather unfortunate timing for the purchase of the second tranche, which merely increased the size of my loss.

TZA: Stopped out.

SRTY: Yet another loss.