Trend Following Code in AmiBroker