[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] HACO corrected code



PureBytes Links

Trading Reference Links

Thanks guys.  Silly mistakes as always.  Indicator is from December TASC not my creation.

 

function ZeroLagTEMA( array, period )

{

 TMA1 = TEMA( array, period );

 TMA2 = TEMA( TMA1, period );

 Diff = TMA1 - TMA2;

 return TMA1 + Diff ;

}

 

/////////////////////

// Heikin-Ashi code

HaClose = (O+H+L+C)/4;

HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );

 

avp = Param("Up TEMA avg", 34, 1, 100 );

avpdn = Param("Dn TEMA avg", 34, 1, 100 );

 

// Velvoort is using not original, but modified Heikin-Ashi close

HaClose = ( HaClose + HaOpen + Max( H, HaOpen ) + Min( L, HaOpen ) )/4;

 

// up average

ZlHa = ZeroLagTEMA( HaClose, avp );

ZlCl = ZeroLagTEMA( ( H + L ) / 2, avp );

ZlDif = ZlCl - ZlHa;

 

keep1 = Hold( HaClose >= HaOpen, 2 );

keep2 = ZlDif >= 0;

keeping = keep1 OR keep2;

keepall = keeping OR ( Ref( keeping, -1 ) AND ( C > O ) OR C >= Ref( C, -1 ) );

keep3 = abs( C - O ) < ( H - L ) * 0.35 AND H >= Ref( L, -1 );

utr = keepall OR ( Ref( keepall, -1 ) AND keep3 );

 

// dn average

ZlHa = ZeroLagTEMA( HaClose, avpdn );

ZlCl = ZeroLagTEMA( ( H + L ) / 2, avpdn );

ZlDif = ZlCl - ZlHa;

 

keep1 = Hold( HaClose < HaOpen, 2 );

keep2 = ZlDif < 0;

keeping = keep1 OR keep2;

keepall = keeping OR ( Ref( keeping, -1 ) AND ( C < O ) OR C < Ref( C, -1 ) );

keep3 = abs( C - O ) < ( H - L ) * 0.35 AND L <= Ref( H, -1 );

dtr = keepall OR ( Ref( keepall, -1 ) AND keep3 );

 

upw = dtr == 0 AND Ref( dtr, -1 ) AND utr;

dnw = utr == 0 AND Ref( utr, -1 ) AND dtr;

 

Haco = Flip( upw, dnw );

 

 

if( ParamToggle("Chart Type", "Price with color back|HACO wave" ) )

{

 Plot( Haco, "Haco", colorRed );

}

else

{

 Plot( C, "Close", colorBlack, ParamStyle( "Style", styleCandle, maskPrice ) );

 Plot( 1, "", IIf( Haco , colorPaleGreen, colorPink ), styleArea | styleOwnScale, 0, 1 );

}

 

 

def_Buy = GetFnData("Beta")>1.1 AND V>1000 AND V>EMA(V,50) AND Close>10;

def_Sell =GetFnData("Beta")>1.1 AND V>1000 AND V>EMA(V,50) AND Close>10;

 

 

Buy  =  def_Buy AND Flip(upw,dnw) AND Ref(Flip(dnw,upw),-1);

Sell =  def_Sell AND Flip(dnw,upw) AND Ref(Flip(upw,dnw),-1);

 

Filter = Buy OR Sell;

 

sector = SectorID(1);

industry = IndustryID(1);

 

AddColumn(IIf(Buy, 66,IIf(Sell, 83,Null )),"Buy/Sell",formatChar,IIf(Buy,colorGreen,IIf(Sell,colorRed,colorDefault)),colorDefault,width = 60);

AddColumn(C,"Close",0,IIf(C>Ref(C,-1),colorGreen,IIf(C<Ref(C,-1),colorRed,colorBlue)));

AddColumn(ROC(C,1),"Change %",0,IIf(C>Ref(C,-1),colorGreen,IIf(C<Ref(C,-1),colorRed,colorBlue)));

AddColumn(V,"Volume",1.0,IIf(V>Ref(V,-1)AND C>Ref(C,-1),colorGreen,IIf(V>Ref(V,-1)AND C<Ref(C,-1),colorRed,colorBlue)),colorDefault);

AddColumn(GetFnData("Beta"),"Beta");

AddTextColumn(Sector,"Sector Name" );

AddTextColumn(Industry,"Industry Name"); 

AddColumn(GetFnData("InsiderHoldPercent"),"Insider Hold Percent");

AddColumn(GetFnData("InstitutionHoldPercent"),"Institution Hold Percent");

 

__._,_.___

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___