Day of Week, Days Held

StrataSearch will find what you tell it to, but what should that be? Will the same criteria work across different Sectors? Different time periods? Here we discuss the ins and outs of OneClick Searches.

Day of Week, Days Held

Postby WebX99 » Wed Aug 08, 2012 12:59 pm

Capture2.JPG
Capture2.JPG (170.88 KiB) Viewed 3866 times
Capture.JPG
Capture.JPG (179.47 KiB) Viewed 3871 times
You can see from the left side of the screen shots above what my entry and exit criteria are.

In the 1st screen shot, I am sometimes getting more than 8 days held even though it should have exited on the next Friday after entry or prior to that if the Primary exit rule kicked in.

In the 2nd screen shot, I am getting entries on Friday even though my entry says DayofWeek() = 4....which should be Thursday.

Ideas on how to get the correct entry and exits would be appreciated. I am trying to work with weekly options which start trading on Thursdays and expire on Fridays 8 days later.
I want to enter on Thursdays and my exit would be either the primary rule exit or exit on the Friday expiration whichever kicks in first.

I appreciat the time and help!
Rick
WebX99
 
Posts: 22
Joined: Thu Aug 02, 2012 1:12 pm

Re: Day of Week, Days Held

Postby WebX99 » Wed Aug 08, 2012 2:03 pm

Ok, I may have a clue...regarding the second screen shot of entries being on Friday instead of Thursday...

In AutoSearch Setups, Order types, the exit code is "ref(open, 1)" which indicates it will enter on the open of the next day.
So I should change "DayOfWeek() = 4" to "DayOfWeek() = 3". :D
WebX99
 
Posts: 22
Joined: Thu Aug 02, 2012 1:12 pm

Re: Day of Week, Days Held

Postby Jaded » Wed Aug 08, 2012 9:40 pm

On your exit, I believe you should also change DayOfWeek() = 5 and $daysheld > 3 to DayOfWeek() = 4 and $daysheld > 2 since the signal occurs on Thursday for a sell signal that happens on Friday. You should then see the results you expect as far as number of days held, which could still roll from one week to the next with that logic.
Jaded
 
Posts: 151
Joined: Mon May 14, 2007 6:49 pm

Re: Day of Week, Days Held

Postby Overload » Thu Aug 09, 2012 8:01 am

That's right, the buy and sell signals are produced the night before the trades are actually entered. This allows you to review your trades before entering them on the next morning. So you will want the signal to take place on Wednesday for a trade that is to be entered on Thursday.

You might also want to add protection for holidays. For example, if New Years falls on your Exit Signal date, you could end up holding the position for an entire extra week based on your current formula. So you might also want to add an additional rule like: $daysheld <= 8

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

Re: Day of Week, Days Held

Postby WebX99 » Thu Aug 09, 2012 10:20 am

Pete and Jaded,

Your comments are a tremendous help! I made the changes you suggested and the entries are on Thursday and exits are on Friday.

While we are on this subject, I noted another situation with the entries overlapping:

SITUATION #1
On Thursdays, when the system is supposed to enter new trades, it still has not exited the positions from the previous Thursday, since the rules say exit the next day... on Friday.
So the system sees my portfolio is already holding the maximum trades allowed and skips the current week.
As a result I am only getting entries every other week.

I will try to brainstorm a workaround but in the meantime, if you tell me what options are available to get around this, that would be appreciated!

SITUATION # 2

There seems to be a leak in the exit logic which is allowing some trades to stay in effect for the life of data. Once this happens, my portfolio has the maximum number of trades and won't trade any more. See the screenshot below. The screen shot is cut off on the right. The code is: DayOfWeek() = 4 and $daysheld > 2 and $daysheld <= 8

Capture.JPG
Capture.JPG (167.59 KiB) Viewed 3844 times


Thanks,
Rick
WebX99
 
Posts: 22
Joined: Thu Aug 02, 2012 1:12 pm

Re: Day of Week, Days Held

Postby Overload » Fri Aug 10, 2012 9:04 am

For Situation #1, there is no getting around this portfolio management issue that I'm aware of. If your portfolio is full until Friday, StrataSearch will not allow you to buy an additional set of trades on the Thursday before. You might want to consider doing a 7-day holding instead of an 8-day. Actually, you could use a 7-day holding and then change the Exit Price on the Order Types tab to be something like ref(open, 2) instead of ref(open, 1). Using this trick, the positions would still technically exit after 7 days, but they would use the exit price from an 8-day holding. Make sure you also check the "Allow Re-Entry of Trades on Day of Exit" box on the Setups > Trade Settings menu, General tab.

For situation #2, I think your exit signal is coming on a holiday and is therefore being missed. You might want to add an additional trading rule such as:

OR $daysheld >= 8

The above would cover any exits that slip through the cracks in situations like holidays.

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

counting daysheld in relation to exit ref(open,2)

Postby WebX99 » Fri Aug 10, 2012 3:29 pm

How do we count days held in relation to the exit code of "ref(open,2)"?

Let's see if I get this right.

DONE: Allow Re-Entry of Trades on Day of Exit" box on the Setups > Trade Settings menu, General tab.

ENTRY: DayofWeek() = 3 with Ref(Open,1)
Signal will trigger on Wednesday and entry will be on Thursday. This is $daysheld #1.

EXIT: DayOfWeek() = 3 and $daysheld > 2 and $daysheld <= 7 OR $daysheld >= 7 with Ref(Open,2)
Signal will trigger on Wednesday and exit will be on Friday.

Thursday is $daysheld #1 (ENTRY)
Friday is $daysheld #2
Monday is $daysheld #3
Tuesday is $daysheld #4
Wednesday is $daysheld #5
Thursday is $daysheld #6
Friday is $daysheld #7 (EXIT)

I am not quite getting the number of days per trade that I hoped to. My days held are 5 right now.
My entries are correctly made on Thursday, but my exits are also on Thursday.

The Detailed Analysis Trades tab says my daysheld is 5 when I enter on a Thursday and exit on the following Thursday.
My logic above would say Thursday to Thursday would be a daysheld of 6.
So I am counting something I should not be counting.

I could live with a Thursday to Thursday entry/exit but it would be nice to exit on Friday.

Thanks!
WebX99
 
Posts: 22
Joined: Thu Aug 02, 2012 1:12 pm

Re: Day of Week, Days Held

Postby Overload » Sat Aug 11, 2012 8:12 am

The best way to look at is that Signals are run each day AFTER the market closes and you've imported that day's price. This is why the default Entry Price is ref(open, 1), which means you will enter at the next day's opening price.

I know you are buying on Thursday and selling on Friday, but you will need to decide if you are buying and selling at the open or close. Your Entry Price and Exit Price will need to be adjusted to match what you're looking for.

As for my tweak, keep in mind that changing the Entry and Exit Prices on the Order Types tab does not change the date. It only changes the price. So you can have an Exit Date of 7/15/2012 and an Exit Price of 7/18/2012. Everything will look like you've exited on 7/15/2012, but if you look at the exit price it will be from 7/18/2012. This isn't a perfect solution, but may help you achieve close to what you want.

Because you're doing something pretty unique, I'd recommend starting with one symbol, and then tracking it through a couple of trades so that you can exactly identify when it is buying and selling. This means tracking the Entry and Exit price to the stock's prices for each day. That will be the best way to understand how it works, and ultimately make it easier for you to program alternate scenarios in the future.

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


Return to OneClick Searches and Scoring

cron