Buy & Hold, Or Buy & Sell?


The importable AIQ EDS file based on Markos Katsanos’ article in July issue of Stocks & Commodities magazine, “Buy & Hold, Or Buy & Sell?” can be obtained on request via email to info@TradersEdgeSystems.com. The code is also available below:

Synopsis….Here is a system that with a few simple rules will reduce drawdown and improve the profitability of your portfolio without having to go short or use put options…

!Buy & Hold, Or Buy & Sell?
!Author: Markos Katsanos, TASC July 2021
!Coded by: Richard Denning, 5/17/2021

C is [close].
C1 is valresult(C,1).
H is [high].
L is [low].
LL3 is lowresult(L,3).
HH3 is highresult(H,3).
LL14 is lowresult(l,14).
HH14 is highresult(H,14).
LL40 is lowresult(L,40).
HH40 is highresult(H,40).
V is [volume].
WilderLen is 2.
ATRlen is WilderLen*2-1.
VIX is TickerUDF("VIX",C).
VIXDN is (VIX/highresult(VIX,15,1)-1)*100.
VIXUP is (VIX/lowresult(VIX,15,1)-1)*100.
VIXDNMIN is -30.
VIXUPMIN is 100.

! AVERAGE TRUE RANGE
HD if hasdatafor(ATRlen+20) >= ATRlen.
TR is Max(H - L,max(abs(C1 - L),abs(C1 - H))). 
ATR is iff(HD,expavg(TR,ATRlen),0).

ATRDN is (ATR/highresult(ATR,15,1)-1)*100.
ATRUP is (ATR/lowresult(ATR,15,1)-1)*100.
UP is (highresult(C,2)/lowresult(C,4)-1)*100.
DN is (lowresult(C,2)/highresult(C,4)-1)*100.
CCH is (lowresult(C,10)/highresult(C,100)-1)*100.
HHB is scanany(C=^highresult(C,4),4) then offsettodate(month(),day(),year()).
VOLUP is V/simpleavg(V,50,HHB-1)*100.
LLB is scanany(C=^lowresult(C,4),4) then offsettodate(month(),day(),year()).
SMA10 is simpleavg(C,10).
BUYINITIAL if SMA10 >= valresult(SMA10,1) 
   AND StochK3 < 40 
   AND hasdatafor(20)>=10.
B2 if UP > 6
  AND (VIXDN<VIXDNMIN OR ATRDN<2*VIXDNMIN) 
  AND CCH<-15 
  AND lowresult(StochK40,^LLB)<25 
  AND lowresult(StochK14,^LLB)<25 
  AND StochK14>=StochK40.
Buy if BUYINITIAL or B2.

SELL if C<simpleavg(C,20) 
  AND DN<-6 
  AND (VIXUP>VIXUPMIN OR ATRUP>2*VIXUPMIN) 
  AND VOLUP>80 AND highresult(StochK40,^HHB)>85 
  AND highresult(StochK14,^HHB)>85 
  AND StochK40>=StochK14.

Stoch3 is (C - LL3) / (HH3 - LL3) * 100.
StochK3 is simpleavg(Stoch3,3).
Stoch14 is (C - LL14) / (HH14 - LL14) * 100.
StochK14 is simpleavg(Stoch14,3).
Stoch40 is (C - LL40) / (HH40 - LL40) * 100.
StochK40 is simpleavg(Stoch40,3).

ShowData if 1.

Figure 7 shows a backtest of the weekly system using the Nasdaq 100 list of stocks from 5/17/1999 to 5/17/2021.

Sample Chart

FIGURE 7: AIQ. Shown here is a summary of the EDS weekly backtest using the Nasdaq 100 list of stocks from 5/17/1999 to 5/17/2021.

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems