// my second AFL program - 27th Sep 2008
// base on countertrend return to normalcy
// buy when price high deviate from 20EMA
// sell when price high come back to 3EMA
// comparing high, 3EMA and 20EMA to tell trend
Downtrend = (High < EMA(Close, 3)) AND
(EMA(Close, 3) < MA(Close, 20));
// conditions for buy and sell signals
Buy = (High < 0.98 * EMA(Close, 20)) AND Downtrend;
Sell = Cross(High, EMA(Close, 3));