Thursday, August 14, 2008

Two High Reverse. . .with a Twist

The chart above was added after the initial post as a clarification of how the 'pyramid entry" and fixed day exit look.


Rob Hanna had a post Tuesday on what's happend with the SPX after 2 days up for the past few months. Being a shameless copycat, I decided to look at performance results for that concept on the IWM over the past 12 months. As I've mentioned before, buying short term weakness is my preferred mode, but this is an example of how selling strength can also produce handsome gains.
Here's the TS2000i code for your viewing enjoyment.

Now Rob sells these code packages, but he does so using TS8.3, which is a little bit different from 2000i, so I hope his potential loss of revenue from my posting this code won't mean he has to settle for that 60 foot yacht instead of the 75 footer he really wanted.
(Rob is actually a really nice guy who's got an enquiring mind and is more than willing to share his extensive trading and backtesting history.)

Inputs: Len1(9);
If Close > High[1] and High[1] > High[2]
Then Sell This Bar at Close;
If BarsSinceEntry = Len1
Then ExitShort This Bar at Close;

As usual, I've put my little twist on things and required the entry trigger to reflect 2 consecutive higher high closes.
Exit is a fixed length. . .9 days. You can test other exits at your convenience.
And for something completely different, I've turned on the "entry pyramid" function so the system entry can trigger again within the 9 day trade period, while still exiting on the original 9th day. Using the pyramid entry almost doubles the number of trades for the year and also doubles the net return, so it works very well in this setup.
24 trades in 12 months = avg 1 every 2 weeks. . .and with and avg holding time of 7 days, this is an active system for short timers.

15 comments:

Will said...

Here's the similar StrategyDesk formula, for any AMTD users following along (if blogger confuses "greater than" etc with HTML tags, I'll re-post with escape codes):

ENTRY (Sell Short at Close)-
Bar[Close,D] > Bar[High,D,1] AND Bar[High,D,1] > Bar[High,D,2]

EXIT (Cover)-
Bar[Date,D,9] = EntryDate

Note: This gives different results than Bob's for the same date range (12 winners, 3 losers), but it's still very profitable, and we can compare actual generated trades if needed to hash out the differences.

Also, SD can't do pyramiding or BreakEven Stops... anything beyond simple entry, simple exit and it's too lame.

bzbtrader said...

Will,
Thanks for sharing the code language. As I mentioned, pyramiding of entries doubles the number of TS trades from 13 to 24.
Also, being able to sell and exitshort at the close of the current bar instead of waiting for the open of the next bar to execute the trade increases ROI.

LP said...

Will: Time for Neoticker...or maybe after we make some real money to pay for the damn thing.

BZB: Nice post on pyramiding. When done the right way, it is probably the best way to trade. A professional once told me that he pyramids into most of his trades (assuming it's within good rules). He put it best by saying that professionals add to winning positions where as amateurs sell out of those winning positions. But the key is when to add to a position and when to sit on hands or cut losses. Good post on the benefits of pyramiding.

Cuccaa said...

I'm sorry, but I'm not generating any trades on the "system", I've checked all the settings, every thing is on, but no trades generated.
Could it be I need to modify this line:
If Close > High[1] and High[1] > High[2]
Or should that be an "input"?
I'm on TS 8.3.

Cuccaa said...

Actually, I'm trying to incorporate the two days up, into the "Sweet Spot" trade on the Q's, where, if the Q's are up two days in a row, and "then", gaps up .03% to .06%, sell at the open, cover when you have a profit of .05%, or at the close, which ever comes first.
I think I'm screwing up on the language for the bars up in a row.

Cuccaa said...

I also feel like the "Sweet Spot" could be reversed, IE, after two days DOWN, and "then", we gap down, buy at the open, sell with a .05% profit, or at the close, blah blah blah.

bzbtrader said...

Cucca,
The first line of the code is not an input. Len1(9)is the Input and needs to be specified as such or you'll get zippo.
Maybe you could post the entire code string you're trying to use.
FYI. . my system is looking for 2 consecutive higher highs, not just higher closes. It makes a little bit of difference in performance, but you should still be seeing most of the trades. Did you cut and paste or are you retyping the code? Make sure you use [ and not ( to define the days. You could probably also email your code string to string to Sysin for his spin (really presumptuous on my part, but I suspect he would be happy to sort it out for you).

stringm said...

Will
Will
If you want two consecutive closing highs, shouldn't the SD code look like:
Bar[Close,D] > Bar[High,D,1] AND
Bar[Close,D,1] > Bar[High,D,2] Same
comment to you BZB, It looks like your second test looks at close over close high. Am I screwed up here?
String

bzbtrader said...

Stringm,
The logic is:
Today's close is higher than yesterday's high, and
yesterday's high is higher than the high 2 days ago.
I think that's what the code says, and the chart bars look like they reflect that intent. I can't comment on the SD code, as I have zip experience with it.
Questions are always welcome as they help to clarify things in my mind as well, and, unbelievable as it may seem, I have been known to make coding mistakes (see Fridays' comments).

stringm said...

"As usual, I've put my little twist on things and required the entry trigger to reflect 2 consecutive higher high closes."

You are right with your comment on the codes yours and Wills. I thought your above comment meant two closes closing above the previous days high. The way yours and Will's code reads the Bar 1 day just has to have a higher high than the bar 2 day, not close above the bar 2 high. I am looking at this right?

String

bzbtrader said...

Today's close is higher than yesterday's high, and yesterday's high is higher than the previous day's high. If True, then Buy today's close.
I think you're trying to make this more difficult than it really is.
Today and yesterday make new highs.

stringm said...

BZB

I am with you. I am not familar with Trade Station code but I could see what Will had coded and it did not match 2 consecutive high closes as you had stated. 2 Consecutive High closes would imply Today's close was higher than yesterday's close, and yesterday's CLOSE was higher than the previous days High. I have been thinking about switching to TS. I was wondering if you can screen with the same criteria that you backtest with. You can with SD, but it is immensely slow. If you screen with TS can you screen for making a new 4-20 day High, and how fast is it for say the NYSE in total? Sorry for all the comments, no need to let through to the blog.

Thanks String

bzbtrader said...

String,
I suggest you contact TS directly and ask them about screening capability. I use TS2000i, which is the old pre-brokerage model and which had Radar Screen and Option Screen as components. The current 8.3 version runs differently and unless another commentor wants to weigh in, I don't want to give you an incorrect response. Since I only trade a couple ETFs, scanning is not a feature I need.

Russ said...

The AMTD formula is looking at future data and will not give accurate results in back testing. The results will be fantastic since you are buying at the start of the day but are using EOD data "Bar[Close,D]" This should be D,1 at best. Russ

bzbtrader said...

Russ,
The [1] refers to yesterday and [2] refers to 2 days ago. The system buys on the close of the current bar, so there is no conflict with executing the trades using EOD data. I'm not familiar with AMTD code langugage, so I can't help you there. If you read through the other comments, especially the exchange with Cucca, you'll see how the TS code logic is set up.
Hope that helps.