Below are the main 3 AFL
_SECTION_BEGIN("315 Basic Cross");
Len01 = Optimize("Len01", Param("Len01", 3, 2, 15, 1), 2, 15, 1);
Len02 = Optimize("Len02", Param("Len02", 15, 10, 100, 1), 10, 100, 1);
ema03 = EMA(C, Len01);
ema15 = EMA(C, Len02);
color03 = IIf(ema03 > Ref(ema03, -1), colorDarkGreen, colorDarkRed);
color15 = IIf(ema15 > Ref(ema15,-1), colorBlue, colorRed);
Plot(ema03, "", color03, styleThick);
Plot(ema15, "", color15, styleThick);
Buy = Cross(ema03, ema15);
Sell = Cross(ema15, ema03);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = Sell;
Cover = Buy;
SetPositionSize(1,4);
PlotShapes(Buy * shapeUpArrow, colorBlue, 0, L);
PlotShapes(Sell * shapeDownArrow, colorRed, 0, H);
_SECTION_END();
_SECTION_BEGIN("EMA Reversal");
// Book everything when ema3 going in the opposite direction of the position for 2 days
FlagUP04 = ema03 < ema15 AND ema03 > Ref(ema03,-1) AND Ref(ema03,-1) > Ref(ema03,-2);
FlagDN04 = ema03 > ema15 AND ema03 < Ref(ema03,-1) AND Ref(ema03,-1) < Ref(ema03,-2);
PlotShapes(FlagUP04 * shapeSmallUpTriangle, colorDarkGreen, 0, L);
PlotShapes(FlagDN04 * shapeSmallDownTriangle, colorOrange, 0, H);
_SECTION_END();
_SECTION_BEGIN("eXTREME RUNs");
//Can Book Profit when Last Candle Not toucing EMA3
FlagUP01 = ema03 > ema15 AND ema03 < L; //Buy Mode Ruaway Profit Part Booking
FlagDN01 = ema03 < ema15 AND ema03 > H; //Short Mode Ruaway Profit Part Booking
PlotShapes(FlagUP01 * shapeHollowCircle, colorBlue, 0, H, 5);
PlotShapes(FlagDN01 * shapeHollowCircle, colorRed, 0, L,-5);
//Take a Contra Position when 2 Full Candles Not toucing EMA3
FlagUP02 = ema03 > ema15 AND ema03 < L AND Ref(ema03,-1) < Ref(L,-1); //Buy Mode Ruaway Contra Entry
FlagDN02 = ema03 < ema15 AND ema03 > H AND Ref(ema03,-1) > Ref(H,-1); //Short Mode Ruaway Contra Entry
PlotShapes(FlagUP02 * shapeHollowDownArrow, colorDarkYellow, 0, H,-20);
PlotShapes(FlagDN02 * shapeHollowUpArrow, colorDarkYellow, 0, L,-20);
_SECTION_END();