A simple Trend-Following Strategy In The S&P 500 (Amibroker And Tradestation Code)
The strategy in plain English:
Buy when the close is above the 200-day moving average, and sell when it crosses below.
Entry and exits are done at the close on the same day as the signal.
Click here for the original article.
Amibroker code:
Buy= cross(close,ma(close,200);
buyprice= close;
sell= cross(ma(close,200),close);
sellprice= close;
Tradestation code:
If close Crosses above average(close,200)
then buy this bar at c;
If close Crosses below average(close,200)
then sell this bar at c;
Disclosure: We are not financial advisors. Please do your own due diligence and investment research or consult a financial professional. All articles are our opinions – they are not suggestions to buy or sell any securities.
