21 April 2012

ZIG HI LO SAR HH LL TS TC

/*
Zig-Hi-Zag-Lo

To use to plot the true Peak High and Trough Low
for study of chart pattern, to create trading system

Modified from http://trader.online.pl/MSZ/e-w-ZigZag_HiLo.html

By TohMz
*/
pr=Param("ZigZag change amount", 5, 0.1,100,0.1);

pk=PeakBars(H,pr)==0;
tr=TroughBars(L,pr)==0;

zzHi=Zig(H,pr);
zzLo=Zig(L,pr);
Avg=(zzHi+zzLo)/2;

x=IIf(pk,zzHi,IIf(tr,zzLo,IIf(Avg>Ref(Avg,-1),H,L)));
zzHiLo=Zig(x,pr);

Plot( zzHiLo, "", ParamColor("Color",colorRed), ParamStyle("Style"));

//-- Delete below, to allow attach to any price chart
_N(Title = StrFormat("{{NAME}}- {{INTERVAL}} {{DATE}} O= %g, H= %g, L= %g, C= %g (%.1f%%) V= " +WriteVal( V, 1.0 ) +"\n{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
PriceStyle = GetPriceStyle();
PriceStyleOpt = ParamStyle("Style") | PriceStyle;

if (PriceStyle==styleCandle)
Plot( C, "", colorWhite, PriceStyleOpt);
else
Plot( C, "", IIf( Close >= Ref(C, -1), colorBlue, colorRed ), PriceStyleOpt);

_SECTION_BEGIN("Sup / Res Lines");
SRswitch = ParamToggle("Sup / Res Lines","On,Off");
CHLswitch = ParamToggle("Hi Low / Close","Hi Low,Close");
NoLines = Param("No of Lines",3,1,10,1);
Sen = Param("Sensitivity",5,1,100,1);

Rcolor=ParamColor( "Res Color", colorGreen );
Rstyle=ParamStyle( "Res Style", styleLine );

Scolor=ParamColor( "Sup Color", colorBrown );
Sstyle=ParamStyle( "Sup Style", styleLine );

y=0;
x=0;

for( i = 1; i < NoLines+1 ; i++ ) { Y[i]=LastValue(Peak(IIf(CHLswitch,C,H),Sen,i)); x[i]=BarCount - 1 - LastValue(PeakBars(IIf(CHLswitch,C,H),Sen,i)); Line = LineArray( x[i], y[i], Null, y[i], 1 ); Plot( IIf(SRswitch,Null,Line), "", Rcolor, Rstyle ); Y[i]=LastValue(Trough(IIf(CHLswitch,C,L),Sen,i)); x[i]=BarCount - 1 - LastValue(TroughBars(IIf(CHLswitch,C,L),Sen,i)); Line = LineArray( x[i], y[i], Null, y[i], 1 ); Plot( IIf(SRswitch,Null,Line), "", Scolor, Sstyle ); } _SECTION_END(); _SECTION_BEGIN("Pivot Indicator"); Q=Param("% Change",2,1,10,1); Z= Zig(C,q ) ; HH=((Z Ref(Z,-2)) AND (Peak(z,q,1 ) >Peak(Z,q,2)));
LH=((Z Ref(Z,-2)) AND (Peak(Z,q,1 ) Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) >Trough(Z,q,2)));
LL=((Z>Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) GraphXSpace = 5;
dist = 0.5*ATR(20);

for( i = 0; i < BarCount; i++ )
{
if( HH [i]) PlotText( "HH", i, H[ i ]+dist[i], colorGreen );
if( LH [i]) PlotText( "LH", i, H[ i ]+dist[i], colorRed );
if( HL [i] ) PlotText( "HL", i, L[ i ]-dist[i], colorGreen);
if( LL[i] ) PlotText( "LL", i, L[ i ]-dist[i], colorRed );

}
_SECTION_END();

16 April 2012

add this line to explore afl

all credit goes to Avadhoot Nasikkar

Have you ever perturbed with ‘1’ & ‘0’ in the Buy/Sell column of the exploration window in the Amibroker?
Just Rejoice!
Put this simple line in your exploration and you shall see ‘Buy’ & ‘Sell’ in the exploration window that too with colour background, green for Buy and Red for Sell.

And that line is-

AddTextColumn( WriteIf(Buy,"BUY",WriteIf(Sell,"SELL","")) , "Buy/Sell", 1.2 , colorBlack, IIf( Buy, colorLime,IIf(Sell,colorRed,colorGreen) ));

My Blog List

Total Pageviews

Search This Blog

Followers