Hi
Kindly do not call me Sir. I am just a member of forum like you.
Disclaimer: The AFL below is an combination of various AFLS provided by senior members.
AFL
icol = IIf ( MA (Close,20) > Ref (MA (Close,20),-1),colorGreen,colorRed);
Plot( MA( close, 20 ),"", icol, styleThick,styleDots);
//Plot( MA( Low, 20), "",icol, styleThick);
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN("swing1");
no=Param( "Swing", 10 , 1, 55 );
//no=20;
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
supres=IIf(avn==1,sup,res);
Buy=a=Cross(C,supres);
Sell=b=Cross(supres,C);
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes(shape, IIf(Buy,colorBlue,colorRed), 0, IIf(Buy,Low,High));
//Plot(supres,"Swing",colorWhite,styleStaircase,styleThick);
Plot (supres,"Swing",colorRed,styleStaircase+styleDots,styleThick,styleDots);
_SECTION_END();
_SECTION_BEGIN("Tops and bottom");
pd = Param("Periods",13,5,144,1);
pds = 2*pd-1;// (Adjustment for Wilders MA)
aa = Close-Ref(Close,-1);
uu = EMA(Max(0,aa),pds);
dd= EMA((Max(0,0-aa)),pds);
rf = IIf(C>2,1000,10000);
c1 = Param("Upper Level",70,50,90,1);
qq1 =100/(100-c1)-1;
ff1 = qq1*dd-uu;
ff2 = ff1/qq1;
f1 = Max(ff1,ff2);
UL = Close + f1*(pds-1)/2;
UL = IIf(UL>C,floor(UL*rf),ceil(UL*rf))/rf;
c2 = Param("Equilibrium",50,50,50,0);
qq2 =100/(100-c2)-1;// [=1]
ff = dd-uu;
MM = Close + ff*(pds-1)/2;
MM = IIf(MM>C,floor(MM*rf),ceil(MM*rf))/rf;
c3 = Param("Lower Level",30,10,50,1);
qq3 =100/(100-c3)-1;
ff1 = qq3*dd-uu;
ff2 = ff1/qq3;
f3 = Min(ff1,ff2);
LL = Close + f3*(pds-1)/2;
LL = IIf(LL>C,floor(LL*rf),ceil(LL*rf))/rf;
band = Param("band width",4,0,15,0.25);
mmu = MM+band;
mmd = MM-band;
Buy=X=Cross( C,LL);
Sell=Y=Cross(UL,C);
PlotShapes(shapeCircle*Buy,colorBlue,0,L,-15);
PlotShapes(shapeCircle*Sell,colorRed,0,H,15);
_SECTION_END();
======================================================