AFL Code required for EMA based strategy

Can anyone please help me with AFL code for below strategy

  1. Buy/Sell: Close on 1 min chart crosses Dialy 13 EMA price. Target: 50 Points, SL: 20 Points
  2. When 1st Buy/Sell signal generated, 2nd signal should come only after either SL or TGT hit.
  3. If SL hit, reverse the trade – Target: 25 points, SL: 20 Points
  4. Once either side (1st signal or SL reverse) target achieved, next signal should come when Close on 1 min chart crosses Dialy 13 EMA price

For the above query and condition check this AFL

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() );
Buy = Cross (Close, EMA( Close, 13 )) ;
Sell = Cross (EMA( Close, 13 ), Close) ;
Target = Buy + 50;
SL = Buy - 20;
Short = Sell;
Cover = Buy;

PlotShapes(IIf(Buy, shapeHollowUpArrow, shapeNone),colorGreen, 0,L, Offset=-30); 
PlotShapes(IIf(Short, shapeHollowDownArrow, shapeNone),colorRed, 0,H, Offset=-30);
Plot( EMA( Close, 200 ),"med ema", colorRed,styleThick); 

_SECTION_END();

HI Algo Geek, Thanks for your reply and code. But my requirement is some what different than regular.
When 1st Buy/Sell signal generated, 2nd signal should trigger only after Target/SL hit.
Above code does not satisfy that condition.

WHAT CODE SHUD BE USED ON TRADERSCRIPT??