.

Previous Higher High Lower Low Detector - Amibroker AFL Code

Click Image To Enlarge. Please Rate And Comment.

Previous Higher High Lower Low Detector

_SECTION_BEGIN(" G M M A");

SetBarsRequired(100000,0);

SetChartOptions(0,chartShowArrows|chartShowDates);


MaxGraph = 12;

//==========Bar count= ==CNBONDRE=========================================================

PlotText("   C= "+LastValue(C),BarCount,LastValue(C),42);
numBars = BarsSince(DateNum()!=Ref(DateNum(),-1))+1;
PlotText("\n   BARS = "+LastValue(numBars),BarCount,LastValue(C),16);

//numBars = BarsSince(DateNum()!=Ref(DateNum(),-1))+1;

//PlotText("\n  VOL="+LastValue(Volume),BarCount,LastValue(Volume),37);

//===============cnb============================================================

/* Green lines */
Graph0= EMA( Close, 3 );
Graph1= EMA( Close, 5 );
Graph2= EMA( Close, 7 );

Graph0Color = Graph1Color = Graph2Color = 5;
Graph0Style = Graph1Style = Graph2Style = 1;

// Yellow lines-  

Graph3= EMA( Close, 9 );
Graph4= EMA( Close, 11 );
Graph5= EMA( Close, 15 );

Graph3Color =Graph4Color =Graph5Color = 42;
Graph3Style =Graph4Style =Graph5Style = 1;
 
/* red lines */

Graph6= EMA( Close, 30 );
Graph7= EMA( Close, 35 );
Graph8= EMA( Close, 40 );
Graph9= EMA( Close, 45 );
Graph10= EMA( Close, 50 );

Graph6Color = Graph7Color = Graph8Color = Graph9Color = Graph10Color = 24;
Graph6Style = Graph7Style = Graph8Style = Graph9Style = Graph10Style = 1;

// SKY COLOR lines-  

Graph11 = EMA( Close, 60 );
Graph11Style = 1;
Graph11Color = 10;


StyleList= ParamList("Chart Style", "Candle,Bar");
style =IIf(StyleList== "Candle",styleCandle, styleBar);

GreenBar = IIf(C > O, True, False);
RedBar = IIf(C < O, True, False);
BarColor = IIf(GreenBar, colorBrightGreen, IIf(RedBar, colorCustom12, colorGrey50));

PlotOHLC(O, H, L, C, "", BarColor, style );

//TimeFrameSet( inWeekly );// weekly // Daily


Q = Param( "% Change", 2, 0.1, 10, 0.1 );

Z = Zig( C , q ) ;

HH = (( Z < Ref(Z, -1) AND Ref(Z, -1) > Ref(Z, -2)) AND (Peak(Z, Q, 1) > Peak(Z, Q, 2)));
LH = ((Z < Ref(Z, -1) AND Ref(Z, -1) > Ref(Z, -2)) AND (Peak(Z, Q, 1) < Peak(Z, Q, 2)));
HL = ((Z > 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) < Trough(Z, Q, 2)));

GraphXSpace = 10;
dist = 0.5 * ATR(20);

for ( i = 0; i < BarCount; i++ )
{
    if ( HH[i] )
        PlotText( "HH", i, H[ i ] + dist[i], colorYellow );

    if ( LH[i] )
        PlotText( "LH", i, H[ i ] + dist[i], colorYellow );

    if ( HL[i] )
        PlotText( "HL", i, L[ i ] - dist[i], colorBlue );

    if ( LL[i] )
        PlotText( "LL", i, L[ i ] - dist[i], colorBlue );

}



a= EMA(Close,5)-(EMA(ATR(1),10)*1.50) ;


Buy= LL OR HL OR(Cross(EMA(C,15),EMA(C,60) )) OR (Cross( C,EMA(a,3))AND EMA(a,15)>EMA(C,30) AND EMA(C,3)>EMA(C,15) AND StochK()>Ref(StochK(),-1) AND StochK()>StochD() AND StochD()<80);
Sell= HH OR LH OR (Cross(EMA(C,60),EMA(C,15) )AND StochD()<30)OR(Cross( EMA(a,3), C ) AND EMA(a,15)< EMA(C,30) AND EMA(C,3)<EMA(C,15) AND StochK()<Ref(StochK(),-1) AND StochK()<StochD() AND StochD()<30);

PlotShapes(Buy * shapeUpTriangle, colorBrightGreen  ,0 ,L , OFFSET= -35);
PlotShapes(Sell * shapeDownTriangle, colorRed , 0 , H , OFFSET = -30 );

Buy = ExRem(Buy,Sell);
Sell= ExRem(Sell,Buy);

Filter = Buy OR Sell;
Color = IIf(Buy, colorGreen,IIf(Sell,colorRed,colorDefault));// ---------CNB-------
AddColumn(TimeFrameGetPrice( "Close",inDaily, -1 )," BUY / SELL ", 1.2 , 1, Color , 80);

//TimeFrameRestore();


//======================================================================

Title =EncodeColor(colorYellow)+ ""+ "-- " + EncodeColor(colorRed)+ "MULTIPLE"+ "  "+ EncodeColor(colorBrightGreen)+"MOVING AVERAGES WITH HH-LL-HL-LH" +"\n" + EncodeColor(colorViolet)+ "CNBONDRE"+ " - " +  Name() + " - " + EncodeColor(colorYellow)+ Interval(2) + EncodeColor(colorYellow) +
 "  - " +EncodeColor(colorCustom11)+ Date() +" - "+"\n" +EncodeColor(colorAqua) +"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+
"Cl-"+C+"  "+ "Vol= "+ WriteVal(V)+"\n";
_SECTION_END();
Previous Post Next Post