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...