Simple Moving average code

I want to create a code to meet following condition;
When the Moving average crosses over, based on candle indicator either buy or short. Once executed exit long with +10 points and stop loss -10 points.
Can this be done?