Short system backtest - is there an error here?

Questions directed to our Support Team. Responses can be expected within 24 hours.

Short system backtest - is there an error here?

Postby Kevin_in_GA » Sun Jun 15, 2014 10:30 am

Hey guys:

I was playing around with a daytrade concept of buying after a certain RSI value was reached during an daily pullback, and then selling at the close. Not entirely sure why but it did horribly. So I flipped it into a short system and the results were stunning. Whenever I get great results I usually find that I have made an error - can't find what it is here so I'll share it with folks to get it validated/invalidated.

The entry code is as follows:

Code: Select all
ref(open,1) < low and //OPEN IS BELOW THE PREVIOUS DAY LOW
ref(low,1) < reversersi(2,10) and  //THE LOW IS BELOW THE INTRADAY PRICE THAT WOULD GIVE AN RSI(2) OF 10 OR LESS
ref(low,1) < bbl(close,10,2.5) and  //THE LOW IS BELOW THE PRIOR DAY'S LOWER BB(10,2.5)
close > 5 and //CLOSE IS ABOVE 5
CLOSE > MOV(C,200,S) AND  //CLOSE IS ABOVE THE 200-DAY SIMPLE MOVING AVERAGE
hadalert(volume * close > 2000000,10)=10  //EVERY DAY FOR THE PAST 10 DAYS THE DOLLAR VALUE OF STOCK TRADED IS ABOVE $2,000,000


The entry order type is a limit order at reversersi(2) = 10

exit code:

Code: Select all
1=1  //THIS FORCES THE CLOSE TO BE AT THE END OF THE DAY


The exit order type is a market order at close. I have posted the exact code for the reversersi() function here already, but have also exported the system results and code and attached it here.

Why do I think there might be a flaw I'm overlooking? Well, for the period 5/30/2007 to 5/30/2014 the results were astounding (see the attached image of the equity curve).

Happy to share this with others in an effort to pressure test this strategy. I have included both commissions ($8.95 per trade), a spread of 0.04, and slippage of 0.05% (not a lot since these results are for the S&P 500). I required that the limit only be executed if it is within the spread and slippage adjusted range. The equity curve shown here is for a portfolio size of 5, fixed equity per trade of $20,000.

new daytrade - short.gif
new daytrade - short.gif (61.63 KiB) Viewed 1246 times
Attachments
NEW SP500 SHORT.sse
(1.02 KiB) Downloaded 126 times
Kevin_in_GA
 
Posts: 171
Joined: Wed Aug 04, 2010 10:14 am

Re: Short system backtest - is there an error here?

Postby Kevin_in_GA » Sun Jun 15, 2014 9:28 pm

Looks like if I remove the references in the entry code to "ref(low,1) ..." the system falls apart. Truth is they should not be needed since the entry is a limit order at reversersi(2,10) and either it gets filled or it doesn't. Having them in there must be biasing the results toward a very profitable outcome, but I don't see why this would be.
Kevin_in_GA
 
Posts: 171
Joined: Wed Aug 04, 2010 10:14 am

Re: Short system backtest - is there an error here?

Postby Overload » Mon Jun 16, 2014 9:09 am

Remember that a ref(____, 1) means "tomorrow". As a general rule, you should never use a positive number in the ref() formula, as that is a reference to future information that would not be available at the time of the trade. There may be a few cases where you want to add an additional limit prior to the opening of the position and correctly look at tomorrow's prices, but you just have to make sure that the information you're getting isn't beyond what would be available at the time of the trade. Here are the 3 lines of code where you're using a forward reference:

ref(open,1) < low and //OPEN IS BELOW THE PREVIOUS DAY LOW

This one should be okay. You're saying that on the day of the trade, the opening price needs to be below the prior day's close for the trade to be eligible. This test would be done before the trade was executed, so it is valid.

ref(low,1) < reversersi(2,10) and //THE LOW IS BELOW THE INTRADAY PRICE THAT WOULD GIVE AN RSI(2) OF 10 OR LESS

This one should be okay too, but it also shouldn't be necessary. If you have a limit order at reversersi(2, 10), then it won't enter the position anyway unless the low gets below that value on the day of the trade. So it's redundant since the limit order does the same thing.

ref(low,1) < bbl(close,10,2.5) and //THE LOW IS BELOW THE PRIOR DAY'S LOWER BB(10,2.5)

This one is the problem. Your description is correct in that it will enter the position when the THE LOW IS BELOW THE PRIOR DAY'S LOWER BB(10,2.5). However, the LOW for the day won't be known until the end of the trading day, so you're basically peeking into the future to verify that the day's LOW will indeed get that low. And then you're only entering the position after confirming that it will be a good trade, or at least that the price will go down significantly that day.

Hopefully this helps, but let me know if you have additional questions on this.

Pete
Overload
 
Posts: 2248
Joined: Wed Nov 30, 2005 12:14 pm


Return to Technical Support