If it is possible for this AFL to not repainted or look for future

#1
Hello Expert ,Senior or friend,


_SECTION_BEGIN("GAP");
SetBarsRequired(sbrAll,sbrAll);
xx=BarIndex();x=xx;Lx=LastValue(x);
rightStrength=Param("Right Strength",5,1,50,1);
leftStrength=Param("Left Strength",5,1,50,1);
showUpGap=ParamToggle("Display Up Gap","No|Yes",1);
showDnGap=ParamToggle("Display Dn Gap","No|Yes",1);

function pkID(rightStrength,leftStrength)
{
pk=H>Ref(HHV(H,leftStrength),-1) AND H>=Ref(HHV(H,rightStrength),rightStrength);
return pk;
}
function trID(rightStrength,leftStrength)
{
tr=L<Ref(LLV(L,leftStrength),-1) AND L<=Ref(LLV(L,rightStrength),rightStrength);
return tr;
}

pk=pkID(rightStrength,leftStrength);
tr=trID(rightStrength,leftStrength);

SetChartBkColor(ColorRGB(0,0,0));
SetChartOptions(0 ,chartShowDates);
SetBarFillColor(IIf(C>O,colorGreen,IIf(C<=O,colorRed,colorLightGrey)));
Plot(C,"Price",IIf(C>O,colorDarkGreen,IIf(C<=O,colorDarkRed,colorLightGrey)),64);
PlotShapes(shapeSmallCircle*tr,IIf(Lx-ValueWhen(tr,x)>rightStrength,ColorRGB(0,100,0),colorWhite),0,L,-10);
PlotShapes(shapeSmallCircle*pk,IIf(Lx-ValueWhen(pk,x)>rightStrength,ColorRGB(255,0,0),colorWhite),0,H,10);

pkHigh1=Ref(ValueWhen(pk,H,1),-(rightStrength+1));
trLow1=Ref(ValueWhen(Tr,L,1),-(rightStrength+1));
pkHigh0=ValueWhen(pk,H,0);
trLow0=ValueWhen(Tr,L,0);

upGap=Cross(C,pkHigh1) AND pkHigh1<trLow0;
dnGap=Cross(trLow1,C) AND trLow1>pkHigh0;

gapBaseUp=ValueWhen(upGap,pkHigh1);
gapBaseDn=ValueWhen(dnGap,trLow1);
gapExtrUp=ValueWhen(upGap,trLow0);
gapExtrDn=ValueWhen(dnGap,pkHigh0);

upGapArea=Flip(upGap,dnGap);
dnGapArea=Flip(dnGap,upGap);

gapBase=IIf(upGapArea,gapBaseUp,gapBaseDn);
gapExtr=IIf(upGapArea,gapExtrUp,gapExtrDn);

upGapBase=IIf(gapExtr>gapBase,gapBase,Null);upGapBase=IIf(Ref(upGap,1),Null,upGapBase);
upGapExtr=IIf(gapExtr>gapBase,gapExtr,Null);upGapExtr=IIf(Ref(upGap,1),Null,upGapExtr);
dnGapBase=IIf(gapExtr<gapBase,gapBase,Null);dnGapBase=IIf(Ref(dnGap,1),Null,dnGapBase);
dnGapExtr=IIf(gapExtr<gapBase,gapExtr,Null);dnGapExtr=IIf(Ref(dnGap,1),Null,dnGapExtr);

Plot(pkHigh1,"",colorBlue,1+styleThick);
Plot(trLow1,"",colorRed,1+styleThick);
if(showUpGap) PlotOHLC(upGapBase,upGapBase,upGapExtr,upGapExtr," ",colorTurquoise,styleCloud|styleNoRescale,0,0,0,-1);
if(showDnGap) PlotOHLC(dnGapBase,dnGapBase,dnGapExtr,dnGapExtr," ",colorCustom16,styleCloud|styleNoRescale,0,0,0,-1);

_SECTION_END();


Above is one afl that look very good for me but only they are repaited and look for future.

Would it be possible to make it not to or anyone have similar or close to this AFL and not to look for future ? Please share.

Thanks & very appreciated
YoungMan