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.

Click here to see the original article.

Amibroker code:

Buy= cross(close,ma(close,200));

buyprice= close;

sell= cross(ma(close,200),close);

sellprice= close;

Tradestation code:

If c>=average(c,200) then buy this bar at close;

if c crosses under average(c,200) then sell this bar at close;

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.