# Swing Trading With Three Indicators

The AIQ code based on Donald Pendergast’s article in the December 2013 issue of Stocks & Commodities, “Swing Trading With Three Indicators,” is provided at the following website: www.TradersEdgeSystems.com/traderstips.htm.

In addition to coding the author’s system as described in his article — which uses the following rules: buy to enter long and sell to exit the longs; short to enter shorts and cover to exit shorts — I created a second system that uses average true range
to get the breakout amount. I also added some additional trend filters
that use the NASDAQ 100 index.

All trading was simulated using closing
prices to determine whether an entry/exit had occurred, and then the
trades are entered/exited the next day at the open. My modified system
uses rules to “BuyATR,” “SellATR,” “ShortATR,” and “CoverATR.” A
comparison of equity curves is shown in Figure 7. In testing the short
side, neither the author’s original system nor my modified system was
able to produce profitable results, although my modified system has a
smaller total loss than the author’s original system.

FIGURE 7: AIQ, EQUITY CURVE. Here is a comparison of the equity curves
for Donald Pendergast’s original system and my modified system trading
the NASDAQ 100 list of stocks for the period 1/5/2000 to 10/9/2013.

```!SWING TRADING WITH THREE INDICATORS
!Author: Donald Pendergast, TASC December 2013
!Coded by: Richard Denning 10/10/2013
!INPUTS:
emaLen is 50.
smaLen is 5.
breakAmt is 0.05.
atrLen is 10.
atrMult is 0.04.
H is [high].
L is [low].
C is [close].
C1 is valresult(C,1).
price is C.
emaLenLT is 200.
!UDFs:
maH is simpleavg(H,smaLen).
maL is simpleavg(L,smaLen).
ema is expavg(C,emaLen).
emaLT is expavg(C,emaLenLT).
TR is Max(H - L,max(abs(C1 - L),abs(C1- H))).
ATR is simpleavg(TR,atrLen).
ATRpct is simpleavg(TR/C,atrLen).
ndxC is tickerUDF("NDX",C).
emaNDX is tickerUDF("NDX",ema).
emaNDXlt is tickerUDF("NDX",emaLT).
!SYSTEM RULES:
!Author's system:
Buy if price > maH+breakAmt and C > ema.
Sell if price < maL.
Short if price < maL-breakAmt and C < ema.
Cover if price > maH.
!Modified system using average true range:
BuyATR if price > maH+atrMult*ATR and C > ema and ndxC < emaNDX and ndxC > emaNDXlt .
SellATR if price < maL-atrMult*ATR.
ShortATR if price < maL-atrMult*ATR and C < ema and ndxC > emaNDX.
CoverATR if price > maH+atrMult*ATR.
```
—Richard Denning