Category Archives: Uncategorized

Market Log 9-18-2012 some signs of topping

The last market Expert Rating 10 days ago was 98-2. WAL (Weighted Action List) and the US (Unconfirmed SIgnals) show a different picture. The WAL analyzes all the high up and down Expert Ratings on the S&P500 that have been confirmed by an independent indicator, in this case the Phase (MACD based). For the 500 stocks analyzed, 24% have ratings to the upside and 76% to downside.

Interstingly the US shows a similar picture 18% have ratings to the upside and 82% to downside. The US is a raw picture of the percenatge of stocks in S&P500 with unconfirmed up vs down high Expert Ratings. Past analysis has shown this US balance is an early indication of a possible change when the balance reaches 15-85 or 85-15.

Emerging Chart Patterns 9-17-2012

Couple of chart patterns appeared in the Chart Pattern EDS report for 9-17-2012.

FEIC emerging pennant

FEIC had a sharp move up at the beginning of August and has since been forming a pennant pattern. The clarity, quality and initial trend for the pattern are very good. The length of the pennant part of the pattern is getting a little long in the tooth but still could resolve. Usually pennants are completed with a breakout to the upside through the upper trendline followed by an increase in volume.

TTMI merging ascending triangle

TTMI has a nice ascending triangle forming, the stock closed at 10.7 today and is still within the triangle. Diminishing volume is typical of this pattern. Breakout occurs usually to the upside through the horizontal trendline and needs to happen with good volume.

More information on Chart Pattern Recognition in TradingExpert Pro can be found at http://www.aiqsystems.com/chartpatterns.htm

Developing A Multilevel Strategy

The AIQ code for Vladimir Vladimirovich Voznjuk’s article in this issue, “Developing A Multilevel Strategy,” is provided at www.TradersEdgeSystems.com/traderstips.htm, and is shown below.

Although AIQ software can chart and test forex data, testing stocks is more interesting. Using the author’s concept of trading using multiple instruments to generate signals, I designed a system that uses both the group index for a stock and the SPX. The multi-instrument indicator that I designed uses the 20-day rate of change in price for the stock and its related group, which is then smoothed by a simple average over 20 days. I then take a ratio of the stock’s smoothed rate of change to its related group’s smoothed rate of change. Finally, I take a stochastic of this ratio (“StoMSG”). The system goes long when the stock, group, and SPX index are in uptrends as measured by the direction of their 50-day simple moving average (higher than it was 10 days ago) and in addition, for the stock and group, the 20-day rate of change is greater than zero. Buy when the trend is up (as defined here) and the StoMSG is less than or equal to 10. Exit longs when one of the following is met: the position has been held for 20 days, or the StoMSG is greater than or equal to 90, or the simple average of the SPX close is less than its value 10 days ago.

To test the multimarket group stock system using the Portfolio Manager for the period 1/1/1999 to 7/18/2012, a trading simulation was run with the following capitalization settings:

 – Maximum of 10 open positions
 – Size each position at 10% of mark-to-market total capital
  – Take no more than 10 new positions per day
  – Compute the mark-to-market capital each day
  – Choose signals based on a relative strength indicator for ranking in descending order for longs (long-only system)

In Figure 1, I show the resulting statistics and equity curve compared to the SPX. The test was run using the S&P 500 group/section structure that can be downloaded from the AIQ website for the period 1/1/1999 to 7/18/2012. AIQ allows for the creation of custom group and sector structures and also has two structures, the S&P 500 and the AIQALL. The S&P 500 groups contain just the stocks in the S&P 500, while the AIQALL groups have most of the stocks that can be traded.

FIGURE 1: AIQ, MULTI-INSTRUMENT TEST SYSTEM. Here is an equity curve for my test system that uses the multi-instrument concept for the period 1/1/1999 to 7/18/2012. The S&P 500 group/sector structure was used for the secondary instruments and the S&P 500 stocks were traded.
 
!DEVELOPING A MULTI-LEVEL STRATEGY
!Author: Vladimir Voznjuk, TASC Sept 2012
!Coded by: Richard Denning 7/16/2012
!www.TradersEdgeSystems.com

! ABBREVIATIONS:
C is [close].
Cx is valresult(C,20).
O is [open].
avgV is simpleavg([volume],50).
PEP is {position entry price}.
PD is {position days}.
Name is description().
Group is tickerUDF(rsTicker(),name).
GrpSym is tickerUDF(rsTicker(),symbol()).
GrpO is tickerUDF(rsTicker(),O).
GrpC is tickerUDF(rsTicker(),C).
GrpCx is valresult(GrpC,20).

!UDFs FOR INDICATOR & SYSTEM:
StkCOPct is simpleavg((C – Cx ) / Cx * 100,20).
GrpCOPct is simpleavg((GrpC – GrpCx) / GrpCx * 100,20).
MA50 is simpleavg(C,50).
GrpMA50  is simpleavg(GrpC,50).
SPXma50  is tickerUDF(“SPX”,MA50).
MSG is StkCOPct / GrpCOPct.

!PLOT THE FOLLOWING WITH 90 & 10 LINES:
StoMSG is (MSG – lowresult(MSG,60)) /
(highresult(MSG,60) – lowresult(MSG,60)) * 100.

!REPORT TO LIST VALUES FOR A SINGLE DAY:
ShowValues if StkCOPct > 0
and MA50 > valresult(MA50,10)
and GrpCOPct > 0
and GrpMA50 > valresult(GrpMA50,10)
and C > 10 and avgV > 3000.

!TRADING SYSTEM RULES:
Buy if StoMSG <= 10
and StkCOPct > 0
and MA50 > valresult(MA50,10)
and GrpCOPct > 0
and GrpMA50 > valresult(GrpMA50,10)
and C > 0 and avgV > 3000
and SPXma50 > valresult(SPXma50,10).
ExitBuy if StoMSG >= 90
or PD >= 20
or SPXma50 < valresult(SPXma50,10).

!FOR RANKING SIGNALS FOR TRADING SIMULATION
!  IN PORTFOLIO MANAGER:
!AIQ RELATIVE STRENGTH:
Price1 is C.
Price2 is O.
MTL is 30.
Q3m is MTL / 4.
Q2m is (MTL – Q3m) / 3.
Q1m is (MTL – Q2m – Q3m) / 2.
Q0m is MTL – Q1m – Q2m – Q3m.
ROCq3m is (valresult(price1,Q2m,(Q1m+Q0m)) /
valresult(price2,Q3m,(Q2m+Q1m+Q0m)) – 1) * 100.
ROCq2m is (valresult(price1,Q1m,Q0m) /
valresult(price2,Q2m,(Q1m+Q0m)) – 1) * 100.
ROCq1m is (valresult(price1,Q0m,0)  /
valresult(price2,Q1m,Q0m) -1 ) * 100.
ROCq0m is (price1 / valresult(price2,Q0m,0) – 1) * 100.
RS_AIQ is ROCq0m * 0.40 + ROCq1m * 0.20
+ ROCq2m * 0.20 + ROCq3m * 0.20. 

AIQ, SECTOR ROTATION MODEL (SRM) INDICATOR

The AIQ code based on Giorgos Siligardos’ article in this issue, “Applying The Sector Rotation Model,” in July 2012 Stocks & Commodities is provided at the following website: www.TradersEdgeSystems.com/traderstips.htm.

Siligardos’ approach relies on sector ETFs. Since sector ETFs have limited price history, I searched for similar sector representations that would have more history. I found that there are S&P 500 sector indexes that start on 9/11/1989 and thus have almost 23 years of history.

In the table in Figure 6, I show the symbols for the sector representations for the three data services DialData from Track Data, Yahoo! from yahoo.com, and PremiumData from Norgate. The first column of the table shows the ETF symbol. The second column shows the AIQALL (a group/sector list structure) sector symbols. You could code the sector rotation indicator using the program-computed sectors as shown, but the results will vary from user to user because the sector values depend on the stocks that are in the user’s database.

Image 6
FIGURE 6: AIQ, SECTORS. Here are the symbols for the sector representations for the three data services DialData, Yahoo, and PremiumData from Norgate.

Since I couldn’t find symbols for some of the sectors at DialData and Yahoo, I decided to use the sector indexes from Norgate (shown in bold in Figure 6). AIQ can use data from any source by using the data transfer utility to import the data from ASCII text files. In the code file I provide, there is an input that allows you to switch between the ETF data symbols and the indexes (useIDX=0 for ETFs and useIDX=1 for indexes).

Please note that I changed the Norgate symbols upon import to remove the “$” as I wasn’t sure this symbol would be allowed as a ticker symbol. So the symbol “$SPXA” from Norgate is changed to “SPXA,” and so on. I have also provided extra code for the other sectors that are not used by the author in case you want to try using different sector combinations in the bull-bear indicator.

Since Siligardos does not provide a mechanical trading system that uses the indicator, I devised one that uses two moving averages of the bull-bear indicator: one set at 50 bars and the other set at 200 bars. Entries to go long occur when the fast average crosses over the slower average. I exit on cross downs or whenever the SPX 50-bar average is lower than it was 10 bars ago.

Since this is mainly a market timing device, I then tried trading the NASDAQ 100 list of stocks using the Portfolio Manager for the period 1/1/1992 to 6/12/2012. The following capitalization settings were used:

  • Maximum of 10 open positions
  • Size each position at 10% of mark-to-market total capital
  • Take no more than 10 new positions per day
  • Compute the mark-to-market capital each day
  • Choose signals based on a relative strength indicator for ranking in descending order for longs (long-only system)

The resulting equity curve is shown in Figure 7, which is compared to the NASDAQ 100 index (NDX). With these settings, the internal rate of return averaged 7.9% with a maximum drawdown of 22.4% on 11/20/1995.

Image 7
FIGURE 7: AIQ, EQUITY CURVE. Here is a sample equity curve for a test system that uses the bull-bear indicator for market timing over the period 1/1/1992 to 6/12/2012. NASDAQ 100 stocks were traded on each buy signal.
The code is also shown below.
!APPLYING THE SECTOR ROTATION MODEL
!Author: Giorgos E. Siligardos, TASC August 2012
!Coded by: Richard Denning 6/6/2012
!www.TradersEdgeSystems.com

!For the US market, the S&P 500 sector exchange traded funds
!(ETFs) or SP500 indexes [IDX] used by author:
 !financial   (XLF) or [SPXF] or [BIX] 
 !consumer discretionary (XLY) or [SPXD] or
 !energy   (XLE) or [SPXE] or [OSX]
 !consumer staples  (XLP) or [SPXS] or 
 !utilities  (XLU) or [SPXU] or [UTY] 
!Other S&P 500 sectors:
 !health care  (XLV) or [SPXA] or [HCX]
 !materials  (XLB) or [SPXM]
 !industrials  (XLI) or [SPXI]
 !telcom   (XLT) or [SPXT]
 !technology  (XLK) or [SPXT]

!INPUTS:
RC_LEN is 95. !LENGTH FOR RATE OF CHANGE 
useIDX is 1. !SWITCHES BETWEEN ETF=0 AND IDX=1

!ABBREVIATIONS:
C is [close].

!CUSTOM FORMULAS:
FIN is iff(useIDX=1,TickerUDF("SPXF",C),TickerUDF("XLF",C)).
CDS is iff(useIDX=1,TickerUDF("SPXD",C),TickerUDF("XLY",C)).
ENE is iff(useIDX=1,TickerUDF("SPXE",C),TickerUDF("XLE",C)).
CSP is iff(useIDX=1,TickerUDF("SPXS",C),TickerUDF("XLP",C)).
UTL is iff(useIDX=1,TickerUDF("SPXU",C),TickerUDF("XLU",C)).
HLT is iff(useIDX=1,TickerUDF("SPXA",C),TickerUDF("XLV",C)).
MAT is iff(useIDX=1,TickerUDF("SPXM",C),TickerUDF("XLB",C)).
IND is iff(useIDX=1,TickerUDF("SPXI",C),TickerUDF("XLI",C)).
TEL is iff(useIDX=1,TickerUDF("SPXL",C),TickerUDF("XLI",C)).
TEK is iff(useIDX=1,TickerUDF("SPXT",C),TickerUDF("XLK",C)).
SPX is TickerUDF("SPX",C).

FINrc is (FIN/valresult(FIN,RC_LEN)-1)*100.
CDSrc is (CDS/valresult(CDS,RC_LEN)-1)*100.
ENErc is (ENE/valresult(ENE,RC_LEN)-1)*100.
CSPrc is (CSP/valresult(CSP,RC_LEN)-1)*100.
UTLrc is (UTL/valresult(UTL,RC_LEN)-1)*100.
HLTrc is (HLT/valresult(HLT,RC_LEN)-1)*100.
MATrc is (MAT/valresult(MAT,RC_LEN)-1)*100.
INDrc is (IND/valresult(IND,RC_LEN)-1)*100.
TELrc is (TEL/valresult(TEL,RC_LEN)-1)*100.
TEKrc is (TEK/valresult(TEK,RC_LEN)-1)*100.

BullSR is (FINrc + CDSrc) / 2.
BearSR is (ENErc + CSPrc + UTLrc) / 3.

!PLOT AS HISTORIGRAM:
BullBearOsc is BullSR - BearSR. 

!PLOT AS TWO LINE INDICATOR WITH ZERO LINE SUPPORT:
BBavgF is simpleavg(BullBearOsc,50).
BBavgS is simpleavg(BullBearOsc,200).

!REPORTS & TRADING SYSTEM USING THE INDICTOR:
List if 1.
FirstDate is firstdatadate().

HD if hasdatafor(200+10) >= 200.
HDsec if TickerRule("XLF",HD) and TickerRule("XLY",HD)
 and TickerRule("XLE",HD) and TickerRule("XLP",HD) 
 and TickerRule("XLU",HD) and TickerRule("SPX",HD).
HDidx if TickerRule("SPXF",HD) and TickerRule("SPXD",HD)
 and TickerRule("SPXE",HD) and TickerRule("SPXS",HD) 
 and TickerRule("SPXU",HD) and TickerRule("SPX",HD).
SPXma is simpleavg(SPX,50).
Buy if BBavgF > BBavgS and valrule(BBavgF < BBavgS,1)
 and ((useIDX=1 and HDidx) or (useIDX<>1 and HDsec)).
xBuy if BBavgF < BBavgS and valrule(BBavgF> BBavgS,1)
 or SPXma < valresult(SPXma,10).

!FOR RANKING STOCKS TO TRADE: 
StockRC is (C/valresult(TEK,RC_LEN)-1)*100.
—Richard Denning

info@TradersEdgeSystems.com

This email address is being protected from spambots. You need JavaScript enabled to view it.

for AIQ Systems

AIQ: EIGHT-BAR SIMPLE MOVING AVERAGE

The AIQ code for the monthly moving average and related system described in “Trading High-Yield Bonds Using ETFs” by Brooke Gardner in this issue is provided at the website noted below.

Although this is a simple moving average system, the use of the monthly
data series presented a challenge, since the EDS module of the AIQ
software does not provide access to a monthly bar. The charting module
does support the monthly chart, but in the EDS code, the monthly bar
cannot be accessed directly.

I tried two different approaches, and both seemed to work. The first
one involved creating a monthly data series by downloading a monthly
.csv file from Yahoo! Finance and then importing the data file into a
newly created ticker using the DTU import utility. This worked but
proved to be too much effort if I wanted to get several bond funds. In
addition, the update would have to be done manually. To use this data
file, we set the input “UseMoDataFile” to 1. Then I tried coding up a
monthly close using daily data files. This took a bit of code but any
daily data file will work, without modification, with this approach. To
use a daily data file, set the “UseMoDataFile” to zero.

The other input parameter allows us to find the end of the month when
using a daily data file. As one option, you could use the first day of
the new month as the signal day by setting “UseEndOfMonthC” to zero.
However, for backtesting and also to match the author’s approach, I set
the “UseEndOfMonthC” to “1” so that we get the signals from the last bar of the month. In the EDS file for the backtest, I then enter on the open of the first bar of the month.

Figure 8 shows a daily chart of VVR with an eight-month moving average.

This code and EDS file can be downloaded from www.TradersEdgeSystems.com/traderstips.htm. (The code is also shown below.

!TRADING HIGH-YIELD BONDS USING ETFs
!Author: Brooke Gardner
!Coded by: Richard Denning 04/17/12
!www.TradersEdgeSystems.com

!INPUTS:
UseMoDataFile is 0.
UseEndOfMonthC is 1.

!ABBREVIATIONS:
C is [close].
O is [open].
C1 is valresult(C,1).
OSD is offsettodate(month(),day(),year()).
SMA8 is simpleavg(C,8).
HD if hasdatafor(21*8+5)>= 21*8.

Mo is month().
Mo1 is valresult(month(),1).
NewMo if Mo <> Mo1.
OneMoBackDate is scanany(NewMo,25,1). 
OneMoBackOS is scanany(NewMo,25,1) then OSD.
TwoMoBackOS is scanany(NewMo,25,^OneMoBackOS+1) then OSD.
ThreeMoBackOS is scanany(NewMo,25,^TwoMoBackOS+1) then OSD.
FourMoBackOS is scanany(NewMo,25,^ThreeMoBackOS+1) then OSD.
FiveMoBackOS is scanany(NewMo,25,^FourMoBackOS+1) then OSD.
SixMoBackOS is scanany(NewMo,25,^FiveMoBackOS+1) then OSD.
SevenMoBackOS is scanany(NewMo,25,^SixMoBackOS+1) then OSD.
EightMoBackOS is scanany(NewMo,25,^SevenMoBackOS+1) then OSD.

Cm is iff(UseEndOfMonthC = 1,C1,C).

MonC1 is valresult(Cm,^OneMoBackOS).
MonC2 is valresult(Cm,^TwoMoBackOS).
MonC3 is valresult(Cm,^ThreeMoBackOS).
MonC4 is valresult(Cm,^FourMoBackOS).
MonC5 is valresult(Cm,^FiveMoBackOS).
MonC6 is valresult(Cm,^SixMoBackOS).
MonC7 is valresult(Cm,^SevenMoBackOS).
MonC8 is valresult(Cm,^EightMoBackOS).

Cmo is iff(NewMo,Cm,MonC1).
Cmo1 is iff(NewMo,MonC1,MonC2).
Cmo2 is iff(NewMo,MonC2,MonC3).
Cmo3 is iff(NewMo,MonC3,MonC4).
Cmo4 is iff(NewMo,MonC4,MonC5).
Cmo5 is iff(NewMo,MonC5,MonC6).
Cmo6 is iff(NewMo,MonC6,MonC7).
Cmo7 is iff(NewMo,MonC7,MonC8).

EightMoSMA is iff(UseMoDataFile=0,(Cmo+Cmo1+Cmo2+Cmo3+Cmo4+Cmo5+Cmo6+Cmo7)/8,SMA8).

Buy if Cmo > EightMoSMA and HD.
Sell if Cmo < EightMoSMA and HD.

ListValues if 1.
 

—Richard Denning

info@TradersEdgeSystems.com
for AIQ Systems