TRADESTATION: HEIKIN-ASHI CANDLES OSCILLATOR LONG TERM (HACOLT)
- Details
- Parent Category: Departments
- Category: Traders' Tips
- Written by Chris Imhof

In “Long-Term Trading Using Exchange Traded Funds” in this issue, author Sylvain Vervoort describes the use of his heikin-ashi candles oscillator (HACO) with modifications for longer-term trading (HACOLT). The indicator plots a 100 value for a long position, 50 for a long exit, and zero for short entry.
We have prepared some EasyLanguage indicator code and example strategy code. See Vervoort’s article for his description of entry and exit conditions for possible entries and exits.
To download the EasyLanguage code for the indicators, first navigate to the EasyLanguage FAQs and Reference Posts Topic in the EasyLanguage support forum (https://www.tradestation.com/Discussions/Topic.aspx?Topic_ID=47452), scroll down, and click on the link labeled “Traders’ Tips, TASC.” Then select the appropriate link for the issue month and year. The ELD filename is “_HACOLT.ELD.”
The code is also shown below.
_HACOLT_Ind ( Indicator )
{ TASC Article, July 2012 }
{ Long-Term Trading Using Exchange Traded Funds }
{ HACOLT by Sylvain Vervoort }
inputs:
avg( 55 ),
CandleSize( 1.1 ),
LTAverage( 60 ) ;
variables:
haOpen( 0 ),
haC( 0 ),
ZlHa( 0 ),
ZlCl( 0 ),
keep1( false ),
keep2( false ),
keeping( false ),
keepall( false ),
keep3( false ),
utr( false ),
dtr( false ),
upw( false ),
dnw( false ),
Result( false ),
LTSell( false ),
LTResult( false ),
PlotValue( 0 ) ;
if CurrentBar > 1 then
haOpen = ( AvgPrice[1] + haOpen[1] ) * 0.5
else
haOpen = Open ;
haC = ( AvgPrice + haOpen + MaxList( High, haOpen )
+ MinList( Low, haOpen ) ) * 0.25 ;
ZlHa = _Tema( haC, avg ) + ( _Tema( haC, avg ) -
( _Tema( _Tema( haC, avg ), avg ) ) ) ;
ZlCl = _Tema( MedianPrice, avg ) +
( _Tema( MedianPrice, avg ) -
( _Tema( _Tema( MedianPrice, avg ), avg ))) ;
keep1 = ( haC >= haOpen or haC[1] >= haOpen[1] ) or
IffLogic( Close >= haC, true,
IffLogic( High > High[1] or Low > Low[1],
true, false ) ) ;
keep2 = ( ZlCl - ZlHa ) >= 0 ;
keeping = keep1 or keep2 ;
keepall = keeping or ( keeping[1] and Close >= Open or
Close >= Close[1] ) ;
keep3 = ( AbsValue( Close-Open ) < Range * CandleSize
and H >= L[1] ) ;
utr = keepall or ( keepall[1] and keep3 ) ;
keep1 = haC < haOpen or haC[1] < haOpen[1] ;
keep2 = ( ZlCl - ZlHa ) < 0 ;
keep3 = AbsValue( Close - Open ) < Range * CandleSize
and Low <= High[1] ;
keeping = keep1 or keep2 ;
keepall = keeping or ( keeping[1] and Close < Open or
Close < Close[1] ) ;
dtr = IffLogic( keepall or ( keepall[1] and keep3 ),
true, false ) ;
upw = dtr = false and dtr[1] and utr ;
dnw = utr = false and utr[1] and dtr ;
Value1 = MRO( upw or dnw, 50, 1 ) ;
Result = IffLogic( upw , true, IffLogic( dnw, false,
IffLogic( Value1 >= 0 and
upw[Value1], true, false ) ) ) ;
LTSell = C < XAverage( Close, LTAverage ) ;
LTResult = IffLogic( Result, true,
IffLogic( Result = false and LTSell,
false, LTResult[1] ) ) ;
if Result = true then
PlotValue = 100
else if Result = false and LTResult = true then
PlotValue = 50
else if Result = false and LTResult = false then
PlotValue = 0 ;
Plot1( PlotValue, "HACOLT" ) ;
{ Alerts }
if AlertEnabled then
begin
if PlotValue = 100 then
begin
if PlotValue[1] = 50 then
Alert( "HACOLT: Long Entry Signal" ) ;
if PlotValue[1] = 0 then
Alert( "HACOLT: Short Exit and Long " +
"Entry Signal" ) ;
end ;
if PlotValue = 50 and PlotValue[1] = 100 then
Alert( "HACOLT: Long Exit Signal" ) ;
if PlotValue = 0 then
begin
if PlotValue[1] = 100 then
Alert( "HACOLT: Long Exit and " +
"SellShort Entry Signal" ) ;
if PlotValue[1] = 50 then
Alert( "HACOLT: SellShort Entry " +
"Signal" ) ;
end ;
end ;
_HACOLT_Strat ( Strategy )
{ TASC Article, July 2012 }
{ Long-Term Trading Using Exchange Traded Funds }
{ HACOLT by Sylvain Vervoort }
inputs:
avg( 55 ),
CandleSize( 1.1 ),
LTAverage( 60 ) ;
variables:
haOpen( 0 ),
haC( 0 ),
ZlHa( 0 ),
ZlCl( 0 ),
keep1( false ),
keep2( false ),
keeping( false ),
keepall( false ),
keep3( false ),
utr( false ),
dtr( false ),
upw( false ),
dnw( false ),
Result( false ),
LTSell( false ),
LTResult( false ),
PlotValue( 0 ) ;
if CurrentBar > 1 then
haOpen = ( AvgPrice[1] + haOpen[1] ) * 0.5
else
haOpen = Open ;
haC = ( AvgPrice + haOpen + MaxList( High, haOpen )
+ MinList( Low, haOpen ) ) * 0.25 ;
ZlHa = _Tema( haC, avg ) + ( _Tema( haC, avg ) -
( _Tema( _Tema( haC, avg ), avg ) ) ) ;
ZlCl = _Tema( MedianPrice, avg ) +
( _Tema( MedianPrice, avg ) -
( _Tema( _Tema( MedianPrice, avg ), avg ))) ;
keep1 = ( haC >= haOpen or haC[1] >= haOpen[1] ) or
IffLogic( Close >= haC, true,
IffLogic( High > High[1] or Low > Low[1],
true, false ) ) ;
keep2 = ( ZlCl - ZlHa ) >= 0 ;
keeping = keep1 or keep2 ;
keepall = keeping or ( keeping[1] and Close >= Open or
Close >= Close[1] ) ;
keep3 = ( AbsValue( Close-Open ) < Range * CandleSize
and H >= L[1] ) ;
utr = keepall or ( keepall[1] and keep3 ) ;
keep1 = haC < haOpen or haC[1] < haOpen[1] ;
keep2 = ( ZlCl - ZlHa ) < 0 ;
keep3 = AbsValue( Close - Open ) < Range * CandleSize
and Low <= High[1] ;
keeping = keep1 or keep2 ;
keepall = keeping or ( keeping[1] and Close < Open or
Close < Close[1] ) ;
dtr = IffLogic( keepall or ( keepall[1] and keep3 ),
true, false ) ;
upw = dtr = false and dtr[1] and utr ;
dnw = utr = false and utr[1] and dtr ;
Value1 = MRO( upw or dnw, 50, 1 ) ;
Result = IffLogic( upw , true, IffLogic( dnw, false,
IffLogic( Value1 >= 0 and
upw[Value1], true, false ) ) ) ;
LTSell = C < XAverage( Close, LTAverage ) ;
LTResult = IffLogic( Result, true,
IffLogic( Result = false and LTSell,
false, LTResult[1] ) ) ;
if Result = true then
PlotValue = 100
else if Result = false and LTResult = true then
PlotValue = 50
else if Result = false and LTResult = false then
PlotValue = 0 ;
{ Entry }
if PlotValue = 100 and PlotValue <> PlotValue[1] then
Buy ( "HACOLT LE" ) next bar market ;
if PlotValue = 0 and PlotValue <> PlotValue[1] then
SellShort ( "HACOLT SE" ) next bar market ;
{ Long Exit }
if PlotValue < 100 then
Sell ( "HACOLT LX" ) next bar market ;
A sample chart is shown in Figure 1.

FIGURE 1: TRADESTATION, HEIKIN-ASHI CANDLES OSCILLATOR LONG TERM (HACOLT). Here is a weekly bar chart of EWW with the indicator (red plot) and strategy applied with a CandleSize of 0.5 for both the indicator and strategy. The cyan plot is the built-in “Mov Avg Exponential” (exponential moving average) indicator set to the close and 60 bars for a 60-bar EMA of the closing prices.
This article is for informational purposes. No type of trading or investment recommendation, advice, or strategy is being made, given, or in any manner provided by TradeStation Securities or its affiliates.


Join us on Facebook
Follow us on Twitter