StockFetcher Forums · General Discussion · To verify Robert Colby's test of moving avg. beats buy&hope<< >>Post Follow-up
slotmarket
59 posts
msg #60469
Ignore slotmarket
3/13/2008 1:49:16 PM

In Colby's book The Encyclopedia of Technical Market Indicators he presented backtest data from 1900 to 2001 totally 102 years. All moving averages crossover beat buy and hope by more than 7 to 1.
"The 5-Day Exponential Moving Average (EMA) crossover is the best simple trend-following indicator we tested against daily DJIA daily closing data from 1900 to 2001. Starting with $100 and reinvesting profits, total net profits for this 5-day EMA Crossover Strategy would have been $16 billion"

I'm trying to verify some of this using the backtester here but must of done it wrong, returning no results.

The filter used is
ind(^DJI)
price closed above MA(5)

Exit trigger is price closed below MA(5)
No stops used and no min or max holding days
Entry and exit price set at Open
Max trades per day 1
Max open position 1
Max selected stocks 1

What am I doing wrong?





chetron
2,817 posts
msg #60480
Ignore chetron
3/13/2008 9:35:23 PM

maybe this....
change the indposition period to the desired responsiveness. what do you think?


Fetcher[

set{var1,indposition(ind(^DJI,close),3)}
set{dji,var1 * 100}
set{vema5,indposition(ema(5),3) * 100}

draw dji on plot dji
draw vema5 on plot dji

vema5 crossed above dji
dji < dji 1 day ago
vema5 > vema5 1 day ago

]





slotmarket
59 posts
msg #60481
Ignore slotmarket
3/14/2008 12:22:04 AM

chetron,

Your filter returned a list of 1494 stocks. Not what I'm trying to do.

The test I'm trying to do is simply buy the index, the Dow, when the price moves above the moving average and sell when price moves below the ma. And see if it beats buy and hold.

I've tried creating a watch list named DJ with only ^DJI in it and running the test on it only.

price closed above MA(200)
and apply to watchlist(DJ)


In a one year test from 3/12/2007 to 3/12/2008, it only returned something from 3/12/07 to 3/20/07. It should not have returned anything because the dow did not crossed the 200ma in those nine days. Something is wrong here.

I don't know where the problem is. Am I writing the wrong filter? Or am I setting the exit trigger incorrectly?

nikoschopen
2,824 posts
msg #60482
Ignore nikoschopen
3/14/2008 3:58:41 AM

One of the main reasons is that StockFetcher will only allow the index to be included in the screening process but not as a direct output. Hence you won't be able to apply the filter to any of the index that it supports. But you can use the ETF of the index in question. As such, you should use DIA for ^DJI, QQQQ for ^IXIC, etc.

Fetcher[
apply to symlist(DIA)
set{Over,count(ind(^DJI,close) crossed above ind(^DJI,EMA(5)),1)}
Over above 0
draw EMA(5)
add column ind(^DJI,close){Close(DJIA)}
add column ind(^DJI,EMA(5)){EMA(DJIA,5)}
]


For cross-reference, I've added new columns for the close of ^DJI and the EMA(5) of ^DJI, respectively. Since no crossover took place today, you prolly won't get any matches.

The below will, however, spit out the match as intended once I replace the phrase "crossed above" for "above".

Fetcher[
apply to symlist(DIA)
set{Xover,count(ind(^DJI,close) above ind(^DJI,EMA(5)),1)}
Xover above 0
draw EMA(5)
add column ind(^DJI,close){Close(DJIA)}
add column ind(^DJI,EMA(5)){EMA(DJIA,5)}
]



guru_trader
485 posts
msg #60483
Ignore guru_trader
modified
3/14/2008 4:03:27 AM

http://www.robertwcolby.com/EMAreport.html


slotmarket
59 posts
msg #60497
Ignore slotmarket
3/14/2008 2:45:02 PM

Niko,
Thanks for you help. We're getting closer, almost there.

I ran a backtest with your filter using ema(200) just so that it will return fewer data point to look at, to test the validity of the backtest output.

Looking a chart of the dow index, it crossed above the ema200 on July 24, 2006 and did not close below until well into 2007. But the backtest returned an exit on Nov. 6, 2006. Is there some kind of bug in the backtest program? The other data points appear to be correct.

Here's the exact filter I used and the backtest data is below:

apply to symlist(DIA)
set{Over,count(ind(^DJI,close) crossed above ind(^DJI,EMA(200)),1)}
Over above 0

Symbol Trigger Date Entry Price Exit Date Exit Price Draw Down Max Profit Gain/
Loss 2 day chg 5 day chg 10 day chg 25 day chg 40 day chg Exit Type
DIA 06/15/2006 109.92 06/19/2006 110.30 -0.19% 0.42% 0.35% -0.68% 0.25% 1.71% -1.24% 1.03% TRIGGER
DIA 06/28/2006 110.23 07/13/2006 109.76 -0.23% 2.11% -0.43% 1.42% 1.78% -1.75% 2.14% 2.33% TRIGGER
DIA 07/19/2006 110.30 07/21/2006 109.60 -0.96% 0.14% -0.63% -1.58% 0.55% 1.52% 2.55% 4.72% TRIGGER
DIA 07/24/2006 110.27 11/06/2006 120.06 -0.34% 10.23% 8.88% 0.58% 1.48% 1.88% 2.87% 4.60% TRIGGER
DIA 08/17/2007 130.96 08/21/2007 130.82 -0.96% 0.57% -0.11% -0.21% 2.05% 1.86% 5.03% 6.92% TRIGGER
DIA 11/13/2007 133.96 11/15/2007 132.16 -1.28% 0.02% -1.34% -1.86% -2.71% -0.84% -1.26% -5.80% TRIGGER
DIA 11/28/2007 132.49 12/18/2007 132.67 -0.60% 4.08% 0.14% 1.26% 1.48% 1.89% -3.26% -6.76% TRIGGER
DIA 12/18/2007 132.51 12/20/2007 132.81 -0.70% 0.46% 0.23% 0.15% 2.20% -1.34% -7.79% -6.93% TRIGGER
DIA 12/20/2007 133.40 12/28/2007 134.22 -0.07% 1.57% 0.61% 1.43% 0.01% -4.00% -6.64% -6.98% TRIGGER

nikoschopen
2,824 posts
msg #60502
Ignore nikoschopen
modified
3/14/2008 6:41:11 PM



TheRumpledOne
6,358 posts
msg #60503
Ignore TheRumpledOne
modified
3/14/2008 8:07:08 PM

""The 5-Day Exponential Moving Average (EMA) crossover is the best simple trend-following indicator we tested against daily DJIA daily closing data from 1900 to 2001. Starting with $100 and reinvesting profits, total net profits for this 5-day EMA Crossover Strategy would have been $16 billion" "

I posted the ema(5) YEARS AGO! Look at my Basic Filter for newbies and old pros.

chetron
2,817 posts
msg #60506
Ignore chetron
3/14/2008 8:56:18 PM

or click the below link..

TRO'S FILTER FOR NEWBIES AND OLD PROS

StockFetcher Forums · General Discussion · To verify Robert Colby's test of moving avg. beats buy&hope<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2016 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus