# Workflow in algorithmic strategies

Sorry for the basic question, I'm trying to educate myself on algorithmic strategies.

Just to see how it works, my idea is to create a simple moving average strategy.

Let us suppose I have $$N$$ observations of the price of an asset $$P_t$$

I define the simple moving average of $$P_t$$ at time $$t$$

$$\text{SMA}_t^{(n)} = {1\over n}\sum_{k=t-n+1}^t P_k~,$$ where $$n$$ is the number of prices included in the average.

• $$\text{BUY}_t$$ when $$P_t < \text{SMA}_t^{(n)}$$
• $$\text{SELL}_t$$ when $$P_t > \text{SMA}_t^{(n)}$$

Every time I have a signal I buy/sell everything I can/have, in other words I maximize the volume of my operations.

My question is how to test this strategy? I tried with the $$SP500$$ index and I found very good results in terms of $$\%$$ returns, but I think my approach is misleading since I should compare it with a buy and hold strategy, considered that this index has only grown in the period that I considered...I also read that simple moving average is good when the market is mean-reverting, and this makes sense to me... What are more appropriate way to test it with real-world data? Also, can you suggest the next steps to make it more realistic?