e = EMA(Close, 20);
UP = Ref(L,-2) > Ref(e,-2) AND Ref(L,-1) > Ref(e,-1) AND H > Max(Ref(H,-1), Ref(H,-2));
DN = Ref(H,-2) < Ref(e,-2) AND Ref(H,-1) < Ref(e,-1) AND L < Min(Ref(L,-1), Ref(L,-2));
UP = ExRem(UP,DN); DN = ExRem(DN,UP);
PlotShapes(UP+2*DN,colorWhite,0,IIf(UP,L,H));