AIQ: SENTIMENT ZONE OSCILLATOR

The AIQ code for Walid Khalil’s sentiment zone oscillator and related system from his article in this issue, “Sentiment Zone Oscillator,” is provided at www.TradersEdgeSystems.com/traderstips.htm.

Using the author’s system that is described in the article, I ran a
test on the NASDAQ 100 list of stocks using the Portfolio Manager
module. 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 three 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.

In Figure 9, I show the equity curve for long-only trading on the
NASDAQ 100 list of stocks for the period 12/31/1999 to 3/16/2012. The
return averaged 10.3% per year with a maximum drawdown of 56.5% on
3/9/2009. The trend filters that are applied to each stock in the system
did not prevent the large drawdown during the two bear markets in the
test period. Applying an index-based trend filter might improve the
results, but I did not try this due to time constraints.

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

!SENTIMENT ZONE OSCILLATOR
!Author: Walid Khailil, TASC May 2012
!Coded by: Richard Denning 3/14/12
!www.TradersEdgeSystems.com

!ABBREVIATIONS:
C  is [close].
C1 is valresult(C,1).
H  is [high].
L  is [low].
O  is [open].
V is [volume].
avgV is expavg(V,50).
smaC is simpleavg(C,10).

!INPUTS:
szoLen is 14.   !SZO PARAMETER
trendEMAlen is 60.  !LENTH FOR TREND DETERMINATION
longLen is 30.  !LONG PERIOD SMOOTHING FOR SZO
percent is 95.  !PERCENTAGE OF RANGE
sellLevel is 7.
filter is 0.24.

!SZO OSCILLATOR:
R is iff(C > C1,1,-1).

rEMA is expavg(R,szoLen).
rTEMA is (3*rEMA) - (3*expavg(rEMA,szoLen)) 
 + (expavg(expavg(rEMA,szoLen),szoLen)).
SZO is 100*(rTEMA / szoLen). 
szoHLP is highresult(SZO,longLen).
szoLLP is lowresult(SZO,longLen).
szoRng is szoHLP - szoLLP.
szoPctRng is szoRng * (percent/100).
szoOB is szoLLP + szoPctRng.
szoOS is szoHLP - szoPctRng.
szoMA is simpleavg(szo,longLen).
EMAtrend is expavg(C,trendEMAlen).

!SZO TRADING SYSTEM RULES:

!BUYING CONDITION RULES:
SZOmaXOzero if szoMA > filter 
 and not valrule(szoMA > filter,1).
TrendUp if C > EMAtrend.
SZOovrSld if SZO < szoOS.
SZOmaUp if SZO > valresult(SZO,1).
SZOgtZero if SZO > 0.
SZOxoLLP if valrule(SZOovrSld,1) and not SZOovrSld.
EMAUp if EMAtrend > valresult(EMAtrend,1).

BuyCond1 if SZOmaXOzero and TrendUP.
BuyCond2 if TrendUp and SZOovrSld 
 and szoMA > valresult(szoMA,1).
BuyCond3 if SZOgtZero and SZOxoLLP and EMAUp.

Buy if BuyCond1 or BuyCond2 or BuyCond3.

!SELLING CONDITION RULES:
SellCond1 if szoMA < -filter 
 and not valrule(szoMA < -filter,1).
SellCond2 if szo < sellLevel 
 and not valrule(szo < sellLevel,1) 
 and szoMA < valresult(szoMA,1).

Sell if SellCond1 or SellCond2.

!RELATIVE STRENGTH UDF FOR SELECTING TRADES:
STL is 32. !RELATIVE STRENGTH LENGTH
Price1 is C. Price2 is C.
aL is STL * 0.25.
RC3 is (valresult(Price1,3*aL)/valresult(Price2,4*aL)-1)*100. 
RC2 is (valresult(Price1,2*aL)/valresult(Price2,3*aL)-1)*100. 
RC1 is (valresult(Price1,1*aL)/valresult(Price2,2*aL)-1)*100. 
RC0 is (valresult(Price1,0*aL)/valresult(Price2,1*aL)-1)*100. 
RS_AIQs is 0.4*RC0 + 0.2*RC1 + 0.2*RC2 + 0.2*RC3.

ShowValues if C > 0.

Leave a Reply