TradingView
muscleriot
4. Jan. 2022 18:20

200DMA last DOM - ajh 

UK 100OANDA

Beschreibung

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.

Versionshinweise

Versionshinweise

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

Versionshinweise

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!

Versionshinweise

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
Kommentare
TradersPostInc
I think the criteria of this strategy might be different than newtraderu.com/2021/06/30/200-day-moving-average-vs-buy-and-hold/

I don't get the same results they show in that blog post. I am not 100% sure but I think dayofmonth(time) == 30 isn't quite accurate since some months have 31 days and some have less. Plus, the 30th day may fall on a weekend. Do you have any idea how we can get the last trading day of month in pinescript?
muscleriot
@TradersPostInc, Thanks for the comment Having backtested this on a few markets, it is not a terrible stratergy, for bull markets, but is not good on choppy sideways markets. It captures bull upmoves and keeps you in, while getting you out on declines. I tested this on bear markets after a bubble and it was not great (It often got you out too late, losing gains). The choice of day of month is arbitary to the 200dma method. If some particular day of month does increase returns it's simply pure luck and not repeatable. I could not see any easy way of updating the script to meet only the last trading day of the month. But it would not make much difference to the way the method works.
muscleriot
@TradersPostInc, Last trading day of month cannot be done using Pinescript. I cannot link it here as the post gets deleted, but on kodify.net there is a outside-month stratergy - that tries to use last trading day of month but explains there is no way.... So you will not get the script to work in the same way as the example.
zions
@TradersPostInc, You can use unit function I wrote - see tradingDaysTillEndOfMonth() here:
tradingview.com/script/Ktb7BHp5-timeUtils/
muscleriot
@zions, Wow - thanks will go through it now.
muscleriot
Updated the code and made the logic a lot clearer.
JSulli518
Hi thanks for making this script! I am wondering why when I backtest this on SPY during the 01/01/2000 - 12/31/2016 timeframe it only give a net profit of 117.89%? This is far off the 317% stated by Steve Burns and even less than buy and hold? Thanks for your thoughts.
Mehr