Modify AFL with Scan and Exploration and Backtest

#1
_SECTION_BEGIN("2 Swing");
no=Param( "Swing", 2, 1, 10 );
tsl_col=ParamColor( "Color", colorCycle );
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);
tsl=IIf(avn==1,sup,res);
Plot(tsl, _DEFAULT_NAME(), tsl_col, styleStaircase); // or styleaArea
Buy=Cross(C,tsl);
Sell=Cross(tsl,C);
shape=Buy*shapeUpArrow + Sell*shapeDownArrow;
PlotShapes(shape,IIf(Buy,tsl_col,tsl_col),0,IIf(Bu y,Low,High));
_SECTION_END();

I would like the experts of the forum to add scan,backtest and exploration
in exploration i would like to have below conditions
1) if in buy then add column 2_swing up , Stoploss for long
bullish as per charts

2) if in sell then add column 2_swing dn , Stoploss for short
bearish as per charts

I TRIED BUT THE STOPLOSS IS NOT CHANGING AS PER DATES AND BAR ALSO TEXT NOT ADD IN THE COLUM
PLS HELP ME WITH THIS SIMPLE THING I WOULD BE THANKFUL TO YOU