These are several different strategies that you can use.
Every time the price drops below the buy point, the algorithm buys. Every time the price surpasses the sell point, the algorithm sells. For this strategy you should research the stock's price ahead of time to determine reasonable buy/sell points.
A simple moving averages takes the arithmetic mean of a stock's price over the past number of days, for example over the previous 5, 10, or 100 days. For this algorithm, you decide how far from the moving average to set the buy and sell points.
A weighted moving average behaves like a simple moving average, but it puts more weight on recent data and less on past data. For this algorithm, you decide how far from the weighted moving average to set the buy and sell points.