Heikin Ashi Oscillator

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
NiC72
Posts: 111
Joined: 02 Nov 2009
Location: Sweden
Has thanked: 39 times
Been thanked: 14 times

Heikin Ashi Oscillator

Postby NiC72 » 20 Mar 2010

Hi,
I have some problem with Heikin Ashi Oscillator..
What is "Tema" and "haC" in easylanguage? it is not supported.
Here is the code:
----------------------------

Code: Select all

inputs:
Avg( 34 );

variables:
TMA1(0),
TMA2(0),
Diff(0),
ZlHa(0),
ZlCl(0),
ZlDif(0) ;

{CrossOver formula}
TMA1= Tema(haC,avg);
TMA2= Tema(TMA1,avg);
Diff= TMA1 - TMA2;
ZlHa= TMA1 + Diff;
TMA1= Tema((H+L)/2,avg);
TMA2= Tema(TMA1,avg);
Diff= TMA1 - TMA2;
ZlCl= TMA1 + Diff;
ZlDif=ZlCl-ZlHa;

Plot1( ZlDif,”ZlDif”);
Plot2(0,”Zero Line”);
----------------------------

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 20 Mar 2010

Hi,
I have some problem with Heikin Ashi Oscillator..
What is "Tema" and "haC" in easylanguage? it is not supported.
Here is the code:
----------------------------

What do you mean by "it is not supported"?
can you copy and paste the error message?


TEMA and HaC are functions; you need to add them with your PLEditor.

Code: Select all

{Function: TEMA}

INPUTS:
PRICE(NumericSeries),
LENGTH(NumericSimple);

TEMA =
(3 * XAVERAGE(PRICE,LENGTH))
- (3 * XAVERAGE(XAVERAGE(PRICE,LENGTH),LENGTH))
+ (XAVERAGE(XAVERAGE(XAVERAGE(PRICE,LENGTH),LENGTH),LENGTH));

Code: Select all

// Function: haC

haC = 0.25 * ( AvgPrice + haOpen + MaxList( High, haOpen )+ Minlist( Low, haOpen )) ;

you will also need the following functions:

Code: Select all

// function: AvgPrice

variables: var0( 1 / 3 ) ;

if Open <> 0 then
AvgPrice = ( Open + High + Low + Close ) * .25
else
AvgPrice = ( High + Low + Close ) * var0 ;

Code: Select all

// Function: haOpen

haOpen = 0.5 * ( AvgPrice + haOpen[1] );

NiC72
Posts: 111
Joined: 02 Nov 2009
Location: Sweden
Has thanked: 39 times
Been thanked: 14 times

Fixed now

Postby NiC72 » 21 Mar 2010

Thanks TJ,

- What do you mean by "it is not supported"?
When I paste Heikin Ashi Oscillator code, "Tema" and "haC" was not a reserved word in easylanguage.

I added the functions as you said and it works great now :-)

glen demarco
Posts: 35
Joined: 16 Nov 2009
Contact:

Postby glen demarco » 02 Jun 2010

The Plot1 and Plot2 statements should be double quoted " " and not the tilde "~". Then I was able to compile it.

sts
Posts: 4
Joined: 12 Mar 2012
Has thanked: 3 times

Re: Heikin Ashi Oscillator

Postby sts » 15 Mar 2012

I have long been using HACO - Heiken Ashi Oscillator (binary) in Metastock
And I found the Multicharts alternative for that oscillator in this page:
http://www.traders.com/documentation/fe ... ips.html#1

But I can't make this indicator plot the "binary wave" as the one you can see
in the screen shot given in the code page.
Can you help me sort this out please?
Attachments
ttfig1.gif
The binary at the bottom of this chart?
(43.41 KiB) Downloaded 2131 times

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Heikin Ashi Oscillator

Postby sptrader » 15 Mar 2012

With a few minor changes you can get the same binary output- try this:

Code: Select all

inputs:
Avg( 34 );

variables:
TMA1(0),
TMA2(0),
Diff(0),
ZlHa(0),
ZlCl(0),
ZlDif(0),
dir(0);{add this}

{CrossOver formula}
TMA1= Tema(haC,avg);
TMA2= Tema(TMA1,avg);
Diff= TMA1 - TMA2;
ZlHa= TMA1 + Diff;
TMA1= Tema((H+L)/2,avg);
TMA2= Tema(TMA1,avg);
Diff= TMA1 - TMA2;
ZlCl= TMA1 + Diff;
ZlDif=ZlCl-ZlHa;


dir = iff(Zldif > 0,1,-1);{add this}
Plot1(dir,"ZlDif");{add this}
Plot2(0,"Zero Line");

sts
Posts: 4
Joined: 12 Mar 2012
Has thanked: 3 times

Re: Heikin Ashi Oscillator

Postby sts » 15 Mar 2012

Dear sptrader thank you for the reply.
But actually the crossover formula is simply the starting point for the HACO-binary:

Code: Select all

[b] { Crossover formula for trend determination }[/b]
[i]TMA1 = TEMA( HaCValue, TEMALength ) ;
TMA2 = TEMA( TMA1, TEMALength ) ;
TMADiff = TMA1 - TMA2 ;
ZlHa = TMA1 + TMADiff ;
TMA1 = TEMA( MedianPrice, TEMALength ) ;
TMA2= TEMA( TMA1, TEMALength ) ;
TMADiff = TMA1 - TMA2 ;
ZlCl = TMA1 + TMADiff ;
ZlDiff = ZlCl - ZlHa ;[/i]
After that point these next calculations are done:

Code: Select all

[b]{basic Heikin-Ashi condition }[/b]
HABasic = HaCValue >= HaOpenValue ;

[b]{trend determination }[/b]
Z1DiffPos = ZlDiff >= 0 ;

[b]{don't let a Doji reverse an uptrend }[/b]
NoDojiReverse = ( AbsValue( Close - Open ) < ( High -
Low ) * 0.35 and High >= Low[1] ) and ( HABasic or
DiffAndLastBasic or UpSigns ) ;

[b]{ if prior bar was Green, then make this one green too }[/b]
DiffAndLastBasic = Z1DiffPos and HABasic[1] ;

[b]{ make one more green if "upwards signs" exist }[/b]
UpSigns = ( ( HABasic[2] and DiffAndLastBasic[1] ) or
UpSigns[1] ) and ( Close >= Open or Close >=
Close[1] ) ;

GreenBar = HABasic or DiffAndLastBasic or UpSigns or
NoDojiReverse ;

if GreenBar then
begin
ColorW = UpTrendColor ;
if ( Close > Close[1] and Open < Close ) or
( Close < Close[1] and Open > Close ) then
Color = UpTrendColor
else
Color = HollowColor ;
end
else
begin
ColorW = DnTrendColor ;
if Close < Close[1] then
begin
if Open > Close then
Color = DnTrendColor
else
Color = HollowColor ;
end
else if Close > Close[1] then
begin
if Open < Close then
Color = HollowColor
else
Color = DnTrendColor ;
end ;
end ;
After all these a FILTERED binary wave is plot as HACO. Actually the Metastock code is almost similar but the main difference is that there is no HallowColor inn that code.Instead, the very same code that calculates the GreenBar (uptrend) is used in the opposite manner to find out the RedBar (downtrend) and then this final decision lines are run:

Code: Select all

upw:=dtr=0 AND Ref(dtr,-1) AND utr;
dnw:=utr=0 AND Ref(utr,-1) AND dtr;
result:=If(upw,1,If(dnw,0,PREV));
result


I can translate it in a straight forward manner like this:

Code: Select all

upw= There is an UPtrend if the previous bar was a RedBar but it changed to a GreenBar
dwn= There is a DownTrend if the previous bar was a GreenBar but it changed to a RedBar
Result= If this is a GreenBar then plot 1 else if this is a RedBar Plot 0 else plot Result[1]
Plot(result)
I have taken all these steps but the resulting indicator's value doesn't change even the selected period is changed? So I quit trying and started looking for a ready to use code...

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Heikin Ashi Oscillator

Postby sptrader » 15 Mar 2012

I was just trying to show a simple way to make a binary indicator from an analog version.
I didn't know that there were so many "rules" needed to confirm the change in binary direction.
If the rules are fixed then maybe a "condition" might work..
condition1= if "rule1" and "rule2" and "rule3" then .....plot1...etc.


Return to “User Contributed Studies and Indicator Library”