The 200-Day Moving Average (Amibroker And Tradestation Code)
The original article can be found here.
This lesson has the code for Jeremy Siegel’s version of the doo-day moving average:
The strategy in plain English
- Buy when the close is 1 percent above the 200-day moving average.
- Sell when the close is 1 percent below the 200-day moving average.
Amibroker code:
MovingAverageEntry= MA(C,200) + (MA(C,200)*.01) ;
MovingAverageExit= MA(C,200) – (MA(C,200)*.01) ;
Buy= Cross(Close,MovingAverageEntry);
buyPrice=Close;
Sell= Cross(MovingAverageEntry,Close);
SellPrice=Close;
TradeStation code:
If c > average(c,200)*1.01 then buy this bar at close;
If c < average(c,200)*0.99 then buy this bar at close;
