Sat05252013

Last update12:00:00 AM

BackHomeS&C MagazineDepartmentsTraders' Tips AIQ: HEIKIN-ASHI CANDLES OSCILLATOR LONG TERM (HACOLT)

AIQ: HEIKIN-ASHI CANDLES OSCILLATOR LONG TERM (HACOLT)

The AIQ code based on Sylvain Vervoort’s article in this issue, “Long-Term Trading Using Exchange Traded Funds,” is provided at the following website: www.TradersEdgeSystems.com/traderstips.htm. It is also shown below.

Due to the use of several recursive calculations, the EDS code runs slowly but if you have patience, it will finish. Using the author’s system described in his article, I used the Portfolio Manager module to run portfolio tests on an 18-country list of ETFs. This list will be posted to my website as an AIQ list file along with the EDS file. The EDS file requires at least three years of data before trading can begin, and the test I ran starts the trading on 1/2/2002 and ends on 5/11/2012. 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 10 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 and ascending order for shorts.

I ran separate backtests of trading long-only and short-only and then, using the consolidation feature, combined the two equity curves (Figure 6), which is compared to the S&P 500 (SPX). With these settings, the internal rate of return averaged 10% with a maximum drawdown of 29.5% on 7/23/2008.

!LONG TERM TRADING USING ETFs
!Author: Sylvain Vervoort TASC July 2012
!Coded by: Richard Denning 5/8/12
!www.TradersEdgeSystems.com
! CODING ABBREVIATIONS:
H is [high].
H1 is valresult(H,1).
L is [low].
L1 is valresult(L,1).
C is [close].
C1 is valresult(C,1).
Op is [open].
V is [volume].
OSD is offsettodate(month(),day(),year()).
HD is hasdatafor(2500).
! INPUTS:
emaLen is 55.
candlesize is 1.1.
LTAverage is 60.
!-------------------------HEIKIN-ASHI------------------------
haCtp is (Op + H +L + C) / 4.
DaysInto is ReportDate() - RuleDate().
end if DaysInto > 60.
endHAO is iff(end,Op, haO).
haO is (valresult(endHAO,1) + valresult(haCtp,1)) / 2.
haH is Max(H,max(haO,haCtp)).
haL is Min(L,min(haO,haCtp)).
haCL is (haCtp + haO + haH + haL) / 4.
!---------------------end HEIKIN-ASHI------------------------
!---------------TYPICAL PRICE ZERO-LAG TEMA------------------
TP is (H+L)/2.
TMA1 is expavg(TP,emaLen).
TMA2 is expavg(TMA1,emaLen).
TMA3 is expavg(TMA2,emalen).
tpTEMA1 is 3*TMA1-3*TMA2+TMA3.
TMA4 is expavg(tpTEMA1,emaLen).
TMA5 is expavg(TMA4,emaLen).
TMA6 is expavg(TMA5,emalen).
tpTEMA2 is 3*TMA4-3*TMA5+TMA6.
Diff2 is tpTEMA1 - tpTEMA2.
zLAGtp is tpTEMA1 + Diff2.
!-----------end TYPICAL PRICE ZERO-LAG TEMA------------------
!-----------------HEIKIN-ASHI ZERO-LAG TEMA------------------
haTMA1 is expavg(haCL,emaLen).
haTMA2 is expavg(haTMA1,emaLen).
haTMA3 is expavg(haTMA2,emalen).
haTEMA1 is 3*haTMA1-3*haTMA2+haTMA3.
haTMA4 is expavg(haTEMA1,emaLen).
haTMA5 is expavg(haTMA4,emaLen).
haTMA6 is expavg(haTMA5,emalen).
haTEMA2 is 3*haTMA4-3*haTMA5+haTMA6.
Diff3 is haTEMA1 - haTEMA2.
zLAGha is haTEMA1 + Diff3.
!----------end HEIKIN-ASHI ZERO-LAG TEMA----------------------
!-----------HACOLT INDICATOR----------------------------------
ZLHa is zLAGha.
ZLCl is zLAGtp.
keep1 if countof(haCL>=haO,2)>=1 or C>=haCL 
or (C<haCL and (H>H1 or L>L1)).
keep2 if (ZLCl-ZLHa)>=0.
keep3 if Abs(C-Op)<(H-L)*CandleSize and H>=L1.
keeping if (keep1 or keep2).
keepall if keeping or (valrule(keeping,1) 
and (C>=Op or keep3)).
utr if keepall or (valrule(keepall,1) and keep3).
keep4 if countof(haCL<haO,2)>=1.
keep5 if (ZLCl-ZLHa)<0.
keep6 if Abs(C-Op)<(H-L)*CandleSize and L<=H1.
keeping2 if keep4 or keep5.
keepall2 if keeping2 or (valrule(keeping2,1) 
and (C<Op or C<C1)). 
dtr if keepall2 or (valrule(keepall2,1) and keep6).
dnw if not utr and valrule(utr,1) and dtr.
upw if not dtr and valrule(dtr,1) and utr.
upw_OS is scanany(upw,250) then OSD.
dnw_OS is scanany(dnw,250) then OSD.
upwORdnwLAST is iff(^upw_OS < ^dnw_OS,1,0).
Result is iff(upw,1,iff(dnw,0,upwORdnwLAST)).
LTema is expavg(C,LTAverage).
LTSell is iff(C < expavg(C,LTAverage),1,0).
endLTResult is iff(end,1, LTResult).
LTResult is iff(Result=1,1,iff(Result=0 
and LTSell=1,0,valresult(endLTResult,1))).
endHACOLT is iff(end,50,HACOLT).
!PLOT THE FOLLOWING AS A SINGLE LINE INDICATOR:
HACOLT is iff(Result=1,100,iff(Result=0 
and LTResult=1,50,iff(Result=0 
and LTResult=0,0,valresult(endHACOLT,1)))).
!-------------end HACOLT INDICATOR--------------------------
!-------------HACOLT TRADING SYSTEM-------------------------
!TRADING SYSTEM RULES:
BUY if HACOLT = 100 and HD >= 3*250.
SELL if HACOLT <= 50.
SHORT if HACOLT = 0 and HD >= 3*250.
COVER if HACOLT = 100.
!------------end HACOLT TRADING SYSTEM----------------------
Image 1

FIGURE 6: AIQ, HACOLT TRADING SYSTEM. Here is a consolidated equity curve for the HACOLT system trading on a list of 18 country ETFs for the period 1/2/2002 to 5/11/2012 (blue curve) compared to the S&P 500 (red curve).

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems


To read the entire issue click here and subscribe today!

PTSK — The Professional Traders' Starter Kit
Home| Working Money Magazine | S&C Magazine | Traders.com Advantage | Online Store | Traders’ Resource
Add a Product to Traders’ Resource | Message Boards | Subscribe/Renew | Free Trial Issue | Article Code | Search

DEPARTMENTS: Advertising | Editorial | Circulation | Employment | Contact Us | BY PHONE: (206) 938-0570

Join us on Facebook     Follow us on Twitter     Follow Us on StockTwits

Bookmark and ShareCopyright © 1996-2013 Technical Analysis, Inc. All rights reserved. Read our disclaimer & privacy statement.

SUBSCRIBE TO OUR FREE
EMAIL NEWSLETTER!