Head Shouders
Head and Shoulders patterns remain a staple in technical analysis, indicating potential trend reversals. Traders rely on Amibroker data feeds to precisely identify and confirm these formations. Accurate recognition of Head and Shoulders patterns aids in strategizing entry and exit points, contributing to trading success.
/_SECTION_BEGIN("Head & Shouders Pattern"); // Set Background SetChartBkGradientFill(ParamColor("Bg Top",colorWhite),ParamColor("Bg Bottom",colorLightYellow)); // x = Cum(1); per = 5; back = 50; inter = 100; s11 = H; s12 = L; //------------------------------------------------------------------------------------------------- /* H & S */ pR = PeakBars( s11, per, 1 ) == 0; endt1 = LastValue(ValueWhen( pR, x, 1 )); medt1 = LastValue(ValueWhen( pR, x, 2 )); startt1= LastValue(ValueWhen( pR, x, 3 )); dt1 = endt1-startt1; C1 = x==endt1 OR x==medt1 OR x==startt1; endR = LastValue(ValueWhen( pR, s11, 1 ) ); medR = LastValue(ValueWhen( pR, s11, 2 ) ); startR = LastValue( ValueWhen( pR, s11, 3 )); // Filter1 = medR>endR AND medR>startR AND abs(startR-endR)<0.02*(startR+endR) AND dt1LastValue(x)-back; MaxGraph = 10; Graph1 = C; Graph1Style=64; GraphXSpace=5; /*H&S Neck Line*/ Aper = medt1-startt1; bper = endt1-medt1; La = LastValue(ValueWhen(x==medt1,LLV(L,Aper))); Lb = LastValue(ValueWhen(x==-1+endt1,LLV(L,bper))); Fa=L==La AND x>startt1 AND x medt1 AND x startt-5,trendlineS,-1e10);Graph3BarColor=5; //------------------------------------------------------------------------------------------------- /*Inverted H & S*/ tpR = TroughBars( s12, per, 1 ) == 0; tendt1 = LastValue(ValueWhen(tpr,x,1)); tmedt1 = LastValue(ValueWhen(tpr,x,2)); tstartt1 = LastValue(ValueWhen(tpr,x,3)); tdt1 = tendt1-tstartt1; C2 = x==tendt1 OR x==tmedt1 OR x==tstartt1; tendR = LastValue(ValueWhen( tpR, s12, 1 ) ); tmedR = LastValue(ValueWhen( tpR, s12, 2 ) ); tstartR = LastValue( ValueWhen( tpR, s12, 3 )); // Filter2=tmedR LastValue(x)-back; Graph1BarColor=IIf(C1 AND Filter1,colorWhite,IIf(C2 AND Filter2,10,1)); /*Inverted H&S Neck Line*/ tAper = tmedt1-tstartt1;tbper=tendt1-tmedt1; Ha = LastValue(ValueWhen(x==tmedt1,HHV(H,tAper))); Hb = LastValue(ValueWhen(x==-1+tendt1,HHV(H,tbper))); tFa = H==Ha AND x>tstartt1 AND x tmedt1 AND x Rstartt-5,trendlineR,-1e10);Graph4BarColor=10; Filter = Filter1 OR Filter2; // NumColumns= 2;/*Graph2=x==-1+tendt1;*/ Column0 = Filter1; Column1 = Filter2; Column0Format=Column1Format=1.0; Column0Name="H&S"; Column1Name="inv H&S"; //------------------------------------------------------------------------------------------------- Title = EncodeColor(colorGold)+Name()+" - "+EncodeColor(colorBrightGreen)+FullName()+"\n "+ EncodeColor(colorGold)+StrFormat(" - Open %g, Hi %g, Lo %g, Close %g ",O,H,L,C )+EncodeColor(colorRed)+" - "+Date()+ " - Volume :"+WriteVal(V,1.0); _SECTION_END();