OPEN-SOURCE SCRIPT

200DMA last DOM - ajh

已更新
Implements and backtests a simple 200 day moving average trend following rules based on last day of month to limits trades to 12 per year.
From the book : 5 BEST Moving Average Strategies (That beat buy and hold) by Steve Burns and Holly Burns

Click on the cog to set the input date range eg; 2000-01-01 to 2016-12-31

The book back tested SP500 returns from 2000-2016 317% using this method vs 125% buy and hold only with less drawdown.

Simple 200 day moving average test and trading on last day of month.
(you may find it trades on next available day close to end of month as not all dates can be traded weekends etc..)
Rules are ;
1. if last day of month and stock over 200 day moving average, then go long 100%
2. if last day of month and stock under 200 day moving average, then close long 100% and goto cash.

Aims to miss market declines and keep you long for upside.

Note: Have found doesn't work well in choppy markets moving sideways like the FTSE100 for same period 2000-2016 and causes losses. Also for many stocks.
發布通知
SPY
發布通知
Please use the ADJ swtich on the chart to get a TOTAL RETURN chart. TOTAL RETURN works better with this as the chart is biased upwards so keeps above the 200 DMA longer and get you out on larger swings down. The original 200 DMA method by Steve Burns used a TOTAL RETURN graph of SPX
發布通知
Cleaned up the code, very easy to read now, but Major longstanding problem is trading at end of month. For some reason it skips whole months!
發布通知
A simple but powerful trading stratergy based on the 200 day moving average.
A stratergy that is astonishingly simple but powerful, and outperforms the market most of the time.
The stratergy is for strongly trending indices like the SP500 index. Please use SPY plus ADJ (at bottom right of screen to get a Total Return chart)
This script should be used on the daily timeframe.
The Rules are simple:
1. Trade once per month, by default on first trading day of month based on the 200 day moving average.
2. If under 200 day moving average - Sell
3. If over 200 day moving average - Buy.

HOW AND WHY IT WORKS SO WELL:
The 200 day moving average is used to detect the market trend.
A single trade per month is used to stop whipsaw losses.

This will help keep you out of down trends but help keep you in rising trends.
You will find this stratergy tested against the SP500 total return chart going back 20 years generally outperforms the market, reducing capital lost to drawdowns (down trends) and getting you fully in on uptrends.
Note: Doesn't work well for non-trending volitile sideways markets where chop creates losses.

Please use the SPY with ADJ on the daily chart to get a TOTAL RETURN chart. It's essential to use a total return chart (meaning dividends and distributions are included) because the steeper trend keeps you in the market upswings longer, detects downtrends below the moving average faster to get you out. That's because the moving averages reflect reality better!

You can test for what works best over a long backtest.
You can change the moving average from 200 to 150 days or whatever you want.
You can change the dates to backtest, and add an offset in days.

This Script owes a lot to Steve and Holly Burns published and backtested stratergy based on the 200 day moving average - see the script code header for more details
200dmabacktestingdatesmonthMoving AveragesstrategyTrend Analysis

開源腳本

在真正的TradingView精神中,這個腳本的作者以開源的方式發佈,這樣交易員可以理解和驗證它。請向作者致敬!您可以免費使用它,但在出版物中再次使用這段程式碼將受到網站規則的約束。 您可以收藏它以在圖表上使用。

想在圖表上使用此腳本?

免責聲明