Category Archives: back testing

A Different Kind of Bond Barbell

The “barbell” approach to bond investing typically involves buying a long-term bond fund or ETF and a short-term bond fund or ETF.  The idea is that the long-term component provides the upside potential while the short-term component dampens overall volatility and “smooths” the equity curve.  This article is not intended to examine the relative pros and cons of this approach.  The purpose is to consider an alternative for the years ahead.

The Current Situation

Interest rates bottomed out several years ago and rose significantly from mid-2016 into late 2018.  Just when everyone (OK, roughly defined as “at least myself”) assumed that “rates were about to establish an uptrend” – rates topped in late 2018 and have fallen off since.  Figure 1 displays ticker TYX (the 30-year treasury yield x 10) so you can see for yourself.

1

Figure 1 – 30-year treasury yields (TNX) (Courtesy AIQ TradingExpert)

2

In terms of the bigger picture, rates have showed a historical tendency to move in 30-year waves.  If that tendency persists then rates should begin to rise off the lows in recent years in a more meaningful way.  See Figure 2.Figure 2 – 60-year wave in interest rates (Courtesy: www.mcoscillator.com)

Will this happen?  No one can say for sure.  Here is what we do know:  If rates decline, long-term treasuries will perform well (as long-term bonds react inversely to the trend in yields) and if rates rise then long-term bond holders stand to get hurt.

So here is an alternative idea for consideration – a bond “barbell” that includes:

*Long-term treasuries (example: ticker VUSTX)

*Floating rate bonds (example: ticker FFRAX)

Just as treasuries rise when rates fall and vice versa, floating rate bonds tend to rise when rates rise and to fall when rates fall, i.e., (and please excuse the use of the following technical terms) when one “zigs” the other “zags”.  For the record, VUSTX and FFRAX have a monthly correlation of -0.29, meaning they have an inverse correlation.

3

Figure 3 displays the growth of $1,000 invested separately in VUSTX and FFRAX since FFRAX started trading in 2000.  As you can see the two funds have “unique” equity curves.

Figure 3 – Growth of $1,00 invested in VUSTX and FFRAX separately

Now let’s assume that every year on December 31st we split the money 50/50 between long-term treasuries and floating rate bonds.  This combined equity curve appears in Figure 4.

4

Figure 4 – Growth of $1,000 50/50 VUSTX/FFRAX; rebalanced annually

Since 2000, long-treasuries have made the most money.  This is because interest rates declined significantly for most of that period.  If interest rise in the future, long-term treasuries will be expected to perform much more poorly.  However, floating rate bonds should prosper in such an environment.

Figure 5 displays some relevant facts and figures.

5

Figure 5 – Relevant performance Figures

The key things to note in Figure 5 are:

*The worst 12-month period for VUSTX was -13.5% and the worst 12-month period for FFRAX was -17.1%.  However, when the two funds are traded together the worst 12-month period was just -5.0%.

*The maximum drawdown for VUSTX was -16.7% and the maximum drawdown for FFRAX was -18.2%.  However, when the two funds are traded together the worst 12-month period was just -8.6%.

Summary

The “portfolio” discussed herein is NOT a recommendation, it is merely “food for thought”.  If nothing else, combining two sectors of the “bond world” that are very different (one reacts well to falling rates and the other reacts well to rising rates) certainly appears to reduce the overall volatility.

My opinion is that interest rates will rise in the years ahead and that long-term bonds are a dangerous place to be.  While my default belief is that investors should avoid long-term bonds during a rising rate environment, the test conducted here suggests that there might be ways for holders of long-term bonds to mitigate some of their interest rate risk without selling their long-term bonds.

Like I said, food for thought.

Jay Kaeppel

Disclaimer:  The data presented herein were obtained from various third-party sources.  While I believe the data to be reliable, no representation is made as to, and no responsibility, warranty or liability is accepted for the accuracy or completeness of such information.  The information, opinions and ideas expressed herein are for informational and educational purposes only and do not constitute and should not be construed as investment advice, an advertisement or offering of investment advisory services, or an offer to sell or a solicitation to buy any security.

Weekly & Daily Stochastics

The AIQ code based on Vitali Apirine’s article in the September issue of Stocks and Commodities, “Weekly and Daily Stochastics, is provided below

Using Apirine’s weekly and daily stochastic indicators and a moving average to determine trend direction, I created an example system (long only) with the following rules:

Enter long next bar at open when all of the following are true:

  1. The 200-day simple average of the NDX is greater than the day before
  2. The 200-day simple average of the stock is greater than the day before
  3. Both the weekly and daily stochastic indicators have been below 20 in the last five days
  4. Both the weekly and daily stochastic indicators are greater than the day before.

I tested three exits. Figure 8 shows a 21-day hold then exit. Figure 9 shows a three-moving-average trend-following exit. Figure 10 shows an exit using only the weekly & daily stochastic, once both are lower than the day before.

Sample Chart

FIGURE 8: AIQ, BUY and HOLD. Here is the sample equity curve (blue) compared to the NDX (red) for the test using a 21-day hold exit.

Sample Chart

FIGURE 9: AIQ, TREND-FOLLOWING EXIT. Here is the sample equity curve (blue) compared to the NDX index (red) for the test using a trend-following exit.

Sample Chart

FIGURE 10: AIQ, W and D STOCHASTIC EXIT. Here is the sample equity curve (blue) compared to the NDX index (red) for the test using the weekly and daily stochastic indicators.

The 21-day hold test showed a 11.2% return with a maximum drawdown of 29.3%. The trend-following exit test showed a 17.6% return with a maximum drawdown of 28.8%. The test using an exit based on only the weekly and daily stochastic indicators showed a return of 2.9% with a maximum drawdown of 32.5%. All the tests used the same entry rule and were run on an old 2016 list of the NASDAQ 100 stocks with the stocks that are no longer trading deleted.

!WEEKLY AND DAILY STOCHASTIC
!Author: Vitali Apirine, TASC Sept 2018
!Coded by: Richard Denning 7/7/2018
!www.TradersEdgeSystems.com

!INPUTS:
Periods is 14.
Periods1 is 3.
Pds is 70. 
Pds1 is 3.
smaLen1 is 70.
exitType is 1.

!ABBREVIATIONS:
C is [close].
H is [high].
L is [low].

!INDICATOR CODE:
STOCD is (C-LOWRESULT(L,Periods))/(HIGHRESULT(H,Periods)-LOWRESULT(L,Periods))*100. 
SD is Simpleavg(Stocd,Periods1).
StocW is (C-LOWRESULT(L,Pds))/(HIGHRESULT(H,Pds)-LOWRESULT(L,Pds))*100.
SW is Simpleavg(Stocw,Pds1).
HD if hasdatafor(1000) >= 500.
SMA200 is simpleavg(C,200).
SMA200ndx is tickerUDF("NDX",SMA200).

!SYSTEM CODE:
Buy if SMA200ndx > valresult(SMA200ndx,1)
          and SMA200 > valresult(SMA200,1)
          and SW > valresult(SW,1) 
          and SD > valresult(SD,1) 
          and countof(SW < 20,5)>=1 
          and countof(SD < 20,5)>=1 
          and HD.
smaLen2 is smaLen1*2.
smaLen3 is smaLen1*4.
SMA1 is simpleavg(C,smaLen1).
SMA2 is simpleavg(C,smaLen2).
SMA3 is simpleavg(C,smaLen3).
PD is {position days}.

!EXIT TYPE 1 USES THE INDICATOR ONLY
!EXIT TYPE 2 IS TREND FOLLOWING
Sell if (SD < valresult(SD,1) and SW < valresult(SW,1) and exitType=1)
       or (exitType = 2 
           and ((Valresult(C,PD)valresult(SMA1,PD) And Cvalresult(SMA2,PD) And Cvalresult(SMA3,PD) And C 250)).

RSS is C/valresult(C,120).
RSL is C/valresult(C,240).

—Richard Denning

info@TradersEdgeSystems.com

for AIQ Systems

When to Buy Energy Stocks

Crude oil and pretty much the entire energy sector has been crushed in recent months. This type of action sometimes causes investors to wonder if a buying opportunity may be forming.

The answer may well be, “Yes, but not just yet.”

Seasonality and Energy

Historically the energy sector shows strength during the February into May period.  This is especially true if the November through January period is negative.  Let’s take a closer look.

The Test

If Fidelity Select Energy (ticker FSENX) shows a loss during November through January then we will buy and hold FSENX from the end of January through the end of May.  The cumulative growth of $1,000 appears in Figure 1 and the yearly results in Figure 2.

1

Figure 1 – Growth of $1,000 invested in FSENX ONLY during Feb-May ONLY IF Nov-Jan shows a loss

2

Figure 2 – % + (-) from holding FSENX during Feb-May ONLY IF Nov-Jan shows a loss

Figure 3 displays ticker XLE (an energy ETF that tracks loosely with FSENX).  As you can see, at the moment the Nov-Jan return is down roughly -15%.

3

Figure 3 – Ticker XLE (Courtesy AIQ TradingExpert)

All of this suggests remaining patient and not trying to pick a bottom in the fickle energy sector. If, however, the energy sector shows a 3-month loss at the end of January, history suggests a buying opportunity may then be at end.

Summary

Paraphrasing here – “Patience, ah, people, patience”.

Jay Kaeppel

Disclaimer:  The data presented herein were obtained from various third-party sources.  While I believe the data to be reliable, no representation is made as to, and no responsibility, warranty or liability is accepted for the accuracy or completeness of such information.  The information, opinions and ideas expressed herein are for informational and educational purposes only and do not constitute and should not be construed as investment advice, an advertisement or offering of investment advisory services, or an offer to sell or a solicitation to buy any security.

Portfolio Strategy Based On Accumulation/Distribution

The AIQ code based on Domenico D’Errico’s article in the August issue of Stocks & Commodities magazine, “Portfolio Strategy Based On Accumulation/Distribution,” is shown below.

“Whether you are an individual trader or an asset manager, your main goal in reading a chart is to detect the intentions of major institutions, large operators, well-informed insiders, bankers and so on, so you can follow them. Here, we’ll build an automated stock portfolio strategy based on a cornerstone price analysis theory.”

!Portfolio Strategy Based on Accumulation/Distribution
!Author: Domenic D'Errico, TASC Aug 2018
!Coded by: Richard Denning 6/10/18
!www.TradersEdgeSystem.com
!Portfolio Strategy Based on Accumulation/Distribution
!Author: Domenic D'Errico, TASC Aug 2018
!Coded by: Richard Denning 6/10/18
!www.TradersEdgeSystem.com

!SET TO WEEKLY MODE IN PROPERTIES
!ALSO VIEW CHARTS IN WEEKLY MODE

!INPUTS:
rLen is 4.
consolFac is 75. ! in percent
adxTrigger is 30.
volRatio is 1.
volAvgLen is 4.
volDelay is 4.

!CODING ABREVIATIONS:
H is [high].
L is [low].
C is [close].
C1 is valresult(C,1).
H1 is valresult(H,1).
L1 is valresult(L,1).

!RANGE ACCUMULATION/DISTRIBUTION:
theRange is hival([high],rLen) - loval([low],rLen).
Consol if theRange < consolFac/100 * valresult(theRange,rLen).
rRatio is theRange/valresult(theRange,4)*100.

!AVERAGE TRUE RANGE ACCUMULATION/DISTRIBUTION:
avgLen is rLen * 2 - 1.	
TR  is Max(H-L,max(abs(C1-L),abs(C1-H))).
ATR  is expAvg(TR,avgLen).

ConsolATR if ATR < consolFac/100 * valresult(ATR,rLen). atrRatio is ATR / valresult(ATR,4)*100. !ADX ACCUMULATION/DISTRIBUTION: !ADX INDICATOR as defined by Wells Wilder rhigh is (H-H1). rlow is (L1-L). DMplus is iff(rhigh > 0 and rhigh > rlow, rhigh, 0).
DMminus is iff(rlow > 0 and rlow >= rhigh, rlow, 0).
AvgPlusDM is expAvg(DMplus,avgLen).
AvgMinusDM is expavg(DMminus,avgLen).           	
PlusDMI is (AvgPlusDM/ATR)*100.	
MinusDMI is AvgMinusDM/ATR*100.	
DIdiff is PlusDMI-MinusDMI. 		
Zero if PlusDMI = 0 and MinusDMI =0.
DIsum is PlusDMI+MinusDMI.
DX is iff(ZERO,100,abs(DIdiff)/DIsum*100).
ADX is ExpAvg(DX,avgLen).

ConsolADX if ADX < adxTrigger. !CODE FOR ACCUMULATIOIN/DISTRIBUTION RANGE BREAKOUT: consolOS is scanany(Consol,250) then offsettodate(month(),day(),year()). Top is highresult([high],rLen,^consolOS). Top0 is valresult(Top,^consolOS) then resetdate(). Bot is loval([low],rLen,^consolOS). AvgVol is simpleavg([volume],volAvgLen). Bot12 is valresult(Bot,12). BuyRngBO if [close] > Top
and ^consolOS <= 5 and ^consolOS >= 1
and Bot > Bot12
and valresult(AvgVol,volDelay)>volRatio*valresult(AvgVol,volAvgLen+volDelay).
EntryPrice is [close].

Sell if [close] < loval([low],rLen,1).
ExitPrice is [close].

Figure 9 shows the summary backtest results of the range accumulation breakout system using NASDAQ 100 stocks from December 2006 to June 2018. The exits differ from the author’s as follows: I used two of the built-in exits — a 20% stop-loss and a profit-protect of 40% of profits once profit reaches 10%.

Sample Chart

FIGURE 9: AIQ. Here are the summary results of a backtest using NASDAQ 100 stocks.

Figure 10 shows a color study on REGN. The yellow bars show where the range accumulation/distribution shows a consolidation.

Sample Chart

FIGURE 10: AIQ. This color study shows range consolidation (yellow bars).

—Richard Denning

info@TradersEdgeSystems.com

for AIQ Systems

A Technical Method For Rating Stocks

The AIQ code based on Markos Katsanos’ article in this issue, “A Technical Method For Rating Stocks,” is shown below.
Synopsis from Stocks & Commodities June 2018
I’s it possible to create a stock rating system using multiple indicators or other technical criteria? If so, how does it compare with analyst ratings? Investors around the world move billions of dollars every day on advice from Wall Street research analysts. Most retail investors do not have the time or can’t be bothered to read the full stock report and rely solely on the bottom line: the stock rating. They believe these ratings are reliable and base their investment decisions at least partly on the analyst buy/sell rating. But how reliable are those buy/sell ratings? In this article I will present a technical stock rating system based on five technical criteria and indicators, backtest it, and compare its performance to analyst ratings.
!A TECHNICAL METHOD FOR RATING STOCKS
!Author: Markos Katsanos, TASC June 2018
!Coded by: Richard Denning, 4/18/18
!www.TradersEdgeSystems.com

!INPUTS:
  MAP is 63. 
  STIFFMAX is 7. 
  VFIPeriod is 130. 
  MASPY is 100. 
  MADL is 100.
  SCORECRIT is 5.
  W1 is 1.
  W2 is 1.
  W3 is 1.
  W4 is 1.
  W5 is 2.
 
!VFI FORMULA: 
  COEF is 0.2.
  VCOEF is 2.5.
  Avg is ([high]+[low]+[close])/3.
  inter is ln( Avg ) - ln( Valresult( Avg, 1 ) ). 
  vinter is sqrt(variance(inter, 30 )).
  cutoff is Coef * Vinter * [Close].
  vave is Valresult(simpleavg([volume], VFIPeriod ), 1 ).
  vmax is Vave * Vcoef.
  vc is Min( [volume], VMax ).
  mf is Avg - Valresult( Avg, 1 ).
  vcp is iff(MF > Cutoff,VC,iff(MF < -Cutoff,-VC,0)).
  vfitemp is Sum(VCP , VFIPeriod ) / Vave.
  vfi is expavg(VFItemp, 3 ).

!STIFFNESS 
  ma100 is Avg. 
  CLMA if [close] < MA100.
  STIFFNESS is countof(CLMA,MAP).

!CONDITIONS:
 ! MONEY FLOW:
   COND1 is iff(VFI>0,1,0). 
 !SIMPLEAVG:
    SMA is simpleavg([close],MADL).                              
    COND2 is iff([close]>SMA,1,0).  
 !SIMPLEAVG DIRECTION:                       
    COND3 is iff(SMA>valresult(SMA,4),1,0).  
!STIFFNESS:                          
    COND4 is iff(STIFFNESS<= STIFFMAX,1,0).  
!MARKET DIRECTION:
    SPY is TickerUDF("SPY",[close]).
    COND5 is iff(EXPAVG(SPY,MASPY)>= 
 valresult(EXPAVG(SPY,MASPY),2),1,0).            

SCORE is  W1*COND1+W2*COND2+W3*COND3+
   W4*COND4+W5*COND5.

 buy if Score>=SCORECRIT and hasdatafor(300)>=268. 
Figure 11 shows the summary results of a backtest using NASDAQ 100 stocks during a generally bullish period from April 2009 to April 2018. Figure 12 shows the backtest using the same list of NASDAQ 100 stocks during a period that had two bear markets (April 1999 to April 2009). The average results are similar except that there are fewer trades during the period that contained the two bear markets. Both backtests use a fixed 21-bar exit.
Sample Chart

FIGURE 11: AIQ, BULL MARKET. Here are the summary results of a backtest using NASDAQ 100 stocks during a generally bullish period from April 2009 to April 2018.
Sample Chart

FIGURE 12: AIQ, BEAR MARKET. Here are the summary results of a backtest using NASDAQ 100 stocks during a period from April 1999 to April 2009 that contained two bear markets.
—Richard Denning info@TradersEdgeSystems.com for AIQ Systems