StockFetcher Forums · Filter Exchange · Super Trend Filter<< 1 2 >>Post Follow-up
novacane32000
309 posts
msg #147925
Ignore novacane32000
5/25/2019 6:29:05 PM

Need help backtesting this filter.

I dug up this filter from Kevin and then manually backtested it on excel going long or short on every trend change the same day it occurs for the sake of ease on the backtest.

Trading SPY
From June 2016 to the present day your account would have grown 20.2% taking all the long trades and exciting when the trend changed on 70 trend changes. Short trades lost 13.6% also on about 70 trades. This makes sense since the market trended up during this time.

From the last qtr of 2017 to present day the filter actually beats the market going long and also makes a profit going short. Prior to that, it underperformed

Now, where I need help and where all can benefit, is finding a way to automate this backtest so we can try different combinations of the MA. I did it the hard way, I looked at the chart and entered the buy and sell price of every SPY trade in an excel sheet and then had my data.

Does anyone have a better idea?

Here is the filter.


/* code by Kevin_in_GA */

/*TRENDSUM*/

/*1. IS THE MA(3) ABOVE THE MA(6)? +1 FOR YES, -1 FOR NO*/
Fetcher[set{var1a, count(ma(3) above ma(6), 1)}
set{var1b, count(ma(3) below ma(6), 1)}
set{var1, var1a - var1b}

/*2. IS THE CLOSE ABOVE THE MA(3)? +1 FOR YES, -1 FOR NO*/
set{var2a, count(close above ma(3), 1)}
set{var2b, count(close below ma(3), 1)}
set{var2, var2a - var2b}

/*3. IS THE CLOSE ABOVE THE MA(6)? +1 FOR YES, -1 FOR NO*/
set{var3a, count(close above ma(6), 1)}
set{var3b, count(close below ma(6), 1)}
set{var3, var3a - var3b}

/*4. IS THE SLOPE OF MA(3) POSITIVE? +1 FOR YES, -1 FOR NO*/
set{var4a, count(ma(3) above ma(3) 1 day ago, 1)}
set{var4b, count(ma(3) below ma(3) 1 day ago, 1)}
set{var4, var4a - var4b}

/*5. IS THE SLOPE OF MA(6) POSITIVE? +1 FOR YES, -1 FOR NO*/
set{var5a, count(ma(6) above ma(6) 1 day ago, 1)}
set{var5b, count(ma(6) below ma(6) 1 day ago, 1)}
set{var5, var5a - var5b}

/*6. IS THE CLOSE ABOVE THE PARABOLIC SAR? +1 FOR YES, -1 FOR NO*/
set{var6a, count(close above Parabolic SAR(0.02,0.2), 1)}
set{var6b, count(close below Parabolic SAR(0.02,0.2), 1)}
set{var6, var6a - var6b}

/*7. IS THE +DI(14) ABOVE THE -DI(14)? +1 FOR YES, -1 FOR NO*/
set{var7a, count(PDI above MDI, 1)}
set{var7b, count(PDI below MDI, 1)}
set{var7, var7a - var7b}

/*SUMMING THE INDIVIDUAL INDICATORS INTO THE TRENDSUM*/
set{sum1, var1 + var2}
set{sum2, sum1 + var3}
set{sum3, sum2 + var4}
set{sum4, sum3 + var5}
set{sum5, sum4 + var6}
set{trendsum, sum5 + var7}
SYMLIST(SPY)

ADD COLUMN TRENDSUM
DRAW MA(3)
DRAW MA(6)
DRAW PARABOLIC SAR
DRAW TRENDSUM
PLOTTYPE{TRENDSUM, ZEROBAR}
DRAW ADX
]





graftonian
815 posts
msg #147942
Ignore graftonian
5/28/2019 8:33:58 AM

By tweaking the parameters for PSAR achieves a very close correlation to the trend filter. Try (0.01, 0.03).
An interesting site for excel nerds:
www.tradinformed.com/2015/01/21/calculate-psar-indicator-revised/

novacane32000
309 posts
msg #147943
Ignore novacane32000
5/28/2019 9:54:13 AM

Thanks
That is the type of backtesting I want to do. Tweak the parameters to see how they work in different markets but my manual process just takes too long.

Thanks for the link , very helpful.

graftonian
815 posts
msg #148085
Ignore graftonian
6/8/2019 3:27:10 PM

Thinking about adding the following to Kevins "supertrend" filter.

/* 8. IS THE VOLUME MORE THAN 25% ABOVE 30 DAY AVG?
/*vol_pct*/
set{vp1, Average Volume(3) - Average Volume(30)}
set{vp2, vp1 / Average Volume(30)}
set{vol_pct, vp2 * 100}
set{var8, count(vol_pct > 25, 1)}

Question: How much of a volume increase would warrant another point in
"trendsum"?

And, since volume increase is a positive in a short situation, how to have a volume increase be a -1 where warranted?

Any other indicators you would like to see added to Kevins work?
Thanx, Graf


nibor100
383 posts
msg #148087
Ignore nibor100
6/8/2019 8:24:52 PM

Perhaps, if you have a way to indicate the Short situation, then using logic in your filter you could either multiply 1 by -1, when the appropriate volume situation is indicated or use Min(1,-1)

Ed S.

novacane32000
309 posts
msg #148088
Ignore novacane32000
6/8/2019 10:01:08 PM

Thanks, Graf
I added the volume and it did make some small adjustments but what I would really like to see is a modification to eliminate some more of the whiplash.

I realize the tradeoff would be staying in downtrends a bit longer and not catching the rallies quite as soon but I am okay with that as I'm trying to find a filter to help me with my 401K management.

shillllihs
4,663 posts
msg #148089
Ignore shillllihs
6/8/2019 11:03:21 PM

Can somebody alter this where there is a negative tremdsum but a big green volume spike, seems very interesting for a long trend.

shillllihs
4,663 posts
msg #148093
Ignore shillllihs
modified
6/9/2019 7:07:49 PM

Yeah the kind of setup like
EXC on December 21, 2018, where that positive volume towers above all while trendsum is below 0.
Show me that filter. Looks golden.

roca1018
108 posts
msg #148094
Ignore roca1018
6/9/2019 8:31:33 PM

I apologize if I missed something but when does the buy signal get initiated?

Rich

Village Elder
62 posts
msg #148098
Ignore Village Elder
6/10/2019 9:11:47 AM

Looking at this filter I'm not sure if a BUY signal is generated, versus it being an assessment of a direction and strength. I get that each of these filter components is often used as a direction or trending indicator. I'm guessing that the sum of these is designed to provide a broad assessment of the current trend.

One could scale in and out based on signal strength. Backtesting that would be a serious pain, though.

StockFetcher Forums · Filter Exchange · Super Trend Filter<< 1 2 >>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 2018 - 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