Detecting Swings

The AIQ code based on Domenico D’Errico’s article in the May 2017 issue of Stocks & Commodities issue, “Detecting Swings,” is provided here.

I tested the author’s four systems using the NASDAQ 100 list of stocks on weekly bars, as did the author, from 3/16/2005 through 3/14/2017. Figure 7 shows the comparative metrics of the four systems using the four-week exit. The results were quite different than the author’s, probably due to a different test portfolio and also a 10-year test period rather than the author’s 20-year period. In addition, my test results show longs only, whereas the author’s results are the average of both the longs and shorts.

Sample Chart

FIGURE 7: AIQ. As coded in EDS, this shows the metrics for the author’s four systems run on NASDAQ 100 stocks (weekly bar data) over the period 3/16/2005 to 3/14/2007.

The Bollinger Band (Buy2) system showed the worst results, whereas the author’s results showed the Bollinger Band system as the best. The pivot system (Buy1) showed the best results, whereas the author’s results showed the pivot system as the worst. I am not showing here the comparative test results for the Sell1 thru Sell4 rules, as all showed an average loss over this test period.

!DECTECTING SWINGS
!Author: Domenico D'Errico, TASC May 2017
!Coded by: Richard Denning, 3/15/17
!www.TradersEdgeSystems.com

!Set to WEEKLY in properties

Low is  [low].
Low1  is valresult(Low,1).
Low2  is valresult(Low,2). 
High is [high].
High1  is valresult(High,1).
High2  is valresult(High,2). 
PivotLow if Low1 < Low2  and Low1 < Low.
PivotHigh if High1 > High2  and High1 > High.

Buy1 if  PivotLow.  
Sell1 if  PivotHigh.    

!Set parameter for bollinger bands to 12 with 2 sigma (weekly) in charts:
Buy2 if [close] > [Lower BB] and valrule([close] <= [Lower BB],1).
Sell2 if [close] < [Upper BB] and valrule([close] >= [Upper BB],1).

!Set parameter for Wilder RSI to 5 (weekly) in charts:
Buy3 if [RSI Wilder] > 40 and valrule([RSI Wilder] <= 40,1).
Sell3 if [RSI Wilder] < 60 and valrule([RSI Wilder] >= 60,1).

Buy4 if [RSI Wilder] < 40  And Low > Low1.
Sell4 if [RSI Wilder] > 60  And High < High1.    

Exit if {position days} >= 4.

The code and EDS file can be downloaded from http://aiqsystems.com/detectingswings.EDS

—Richard Denning

info@TradersEdgeSystems.com

for AIQ Systems

Leave a Reply