The importable AIQ EDS file based on Perry Kaufman’s article in this issue, “A Fresh Look At Short-Term Patterns (With And Without A Trend Filter),” can be obtained on request via email to info@TradersEdgeSystems.com. The code is also available below.
!A Fresh Look At Short-Term Patterns !Author: Perry J. Kaufman, TASC Jan 2021
!Coded by: Richard Denning 11/18/2020
C is [close].
C1 is valresult(C,1).
O is [open].
H is [high].
H1 is valresult(H,1).
L is [low].
L1 is valresult(L,1).
L2 is valresult(L,2).
TrendLen is 80.
ATRlen is 20.
OSD is offsettodate(month(),day(),year()).
HD if hasdatafor(ATRlen+20) >= ATRlen.
TR is Max(H - L,max(abs(C1 - L),abs(C1 - H))).
ATR is iff(HD,simpleavg(TR,ATRlen),0).
TR1 is valresult(TR,1).
TR2 is valresult(TR,2).
TR3 is valresult(TR,3).
TR4 is valresult(TR,4).
ATR1 is valresult(ATR,1).
!Key reversals a higher high followed by a lower close.
! We sell the lower close. The opposite for buy signals.
BearKeyR if H > H1 and C < C1.
BullKeyR if L < L1 and C > C1.
!Island reversals a gap higher followed by a lower close,
! but not filling the gap.
!We sell the lower close. The opposite for buy signals.
BearIslandR if L > H1 and C < O.
BullIslandR if H < L1 and C > O.
!Outside days a higher high and a lower low, but the !close in the upper or lower 25% of the range.
!We buy if upper, sell if lower.
BearOutside if H > H1 and L < L1 and C < (L + (H-L)*0.25).
BullOutside if H > H1 and L < L1 and C > (H - (H-L)*0.25).
!Wide-ranging days the same as outside days, but the
! true range must exceed 1.5 × 20-day average true range.
BearWide if H > H1 and L < L1 and C < (L + (H-L)*0.25) and TR > 1.5*ATR.
BullWide if H > H1 and L < L1 and C > (H - (H-L)*0.25) and TR > 1.5*ATR.
!Compression the most recent 3 days must each have a ! true range smaller than the 4th previous day.
! We buy a breakout above the highest high of the !last 3 days and sell a breakout below the lowest low of the past 3 days.
BearComp if TR4 > TR1 and TR4 > TR2 and TR4 >TR3 and L < lowresult(L,3,1).
BullComp if TR4 > TR1 and TR4 > TR2 and TR4 >TR3 and H > highresult(H,3,1).
!Gap openings must be larger than 0.5 × 20-day ATR.
! We buy or sell the close of the gap day in the direction of the opening gap.
BearGap if ((C1-O)/ATR1) > 0.5*ATR1 and O < C1. BullGap if ((O-C1)/ATR1) > 0.5*ATR1 and O > C1. !Trend Filter: SMATrend is simpleavg(C,TrendLen).
SMATrend1 is valresult(SMATrend,1). UpTrend if SMATrend > SMATrend1.
DnTrend if SMATrend < SMATrend1. !Patterns with Trend Filter: BearKeyRTrend if BearKeyR and DnTrend. BullKeyRTrend if BullKeyR and UpTrend.
BearIslandRTrend if BearIslandR and DnTrend. BullIslandRTrend if BullIslandR and UpTrend. BearWideTrend if BearWide and DnTrend.
BullWideTrend if BUllWide and UpTrend. BearCompTrend if BearComp and DnTrend.
BullCompTrend if BullComp and UpTrend. BearGapTrend if BearGap and DnTrend.
BullGapTrend if BullGap and UpTrend.
Code for short-term patterns in the article is included in the EDS file both with and without the trend filter. I ran a portfolio simulation trading NASDAQ 100 stocks with the Bull Outside Day pattern from 1999 to 2020. The equity curve (blue) compared to the NASDAQ index (red) is shown in Figure 13 and the ASA report for the test is shown in Figure 14.
FIGURE 13: AIQ. Equity curve (blue) for Bull Outside Day pattern compared to the NASDAQ 100 index (red) from 1999 to 2020, all trades closed on 4th bar’s open after entry.
FIGURE 14: AIQ. Account Statistics Analysis report for the portfolio simulation.
for AIQ Systems