Simple Moving Average

I want to Buy and Sell Alert based on the Simple Moving Average.If the Simple Moving Average of Close for 50 days is greater than the previous value I want to create an Buy Alert. If the Simple Moving average of Close for 50 days is lesser then the previous value I want to create an Sell alert.