How to exit at target amount or close

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

How to exit at target amount or close

Postby mandelmus » Thu Dec 20, 2012 10:18 pm

I just read the thread, "entry AND exit on day of signal" ... http://www.stratasearch.com/forum/viewtopic.php?f=3&t=1028&start=0 ... several times and still trying to figure out exactly how to set this up properly.

What's the proper way to set up these types of strategies?

Scenario 1
1) enter trade long at open
2) exit the same day at either a) a specified dollar gain (or % gain) or b) the close of the same day

Scenario 2
1) enter trade long at open
2) exit 2 days later at either a) a specified dollar gain (or % gain) or b) the close 2 days later

Scenario 3
1) enter trade long at open
2) exit any day later at either a) a specified dollar gain (or % gain) or b) the lowest low within the past 20 days

I would like to determine "exiting at the specified dollar gain (or % gain)" as occuring if the high was greater than the target amount. So, for example, if my target dollar amount is 0.30 cents above the open and the high was 0.32 cents above the open, I would assume that I was able to exit with the 0.30 cents gain. If the high never went above the target amount, then I would assume that I missed the target and exited at the close of the same day. How would I set up these types of conditions?
mandelmus
 
Posts: 141
Joined: Fri Dec 23, 2011 1:51 pm

Re: How to exit at target amount or close

Postby Overload » Fri Dec 21, 2012 9:25 am

There are 2 ways to exit on an intraday basis. The first is to enter a Stop or Limit Order as your Exit Order Type, and the second is to add a GTCStop() or GTCLimit() formula to your Exit String.

Since you mentioned that you want to exit at the Close Price if the intraday price target is not hit, you will be forced to use the second method and enter a "Market" Order Type for your exit, with a Market Price of "close". In short, this is one piece of how you set a default exit if the intraday price target is not hit. The other piece is to force an immediate exit in your Exit String by using something like this: $daysheld >= 0

Since your Exit Order Type is now being used as a default exit at the Close Price, your only option to exit on an intraday basis is to use the GTCStop() or GTCLimit() formulas within your Exit String. While these do not allow you to set a dollar gain/loss, they can be used to set a percent gain/loss.

With that in mind, here's how your scenarios would work:

Scenario 1
1) enter trade long at open
2) exit the same day at either a) a specified dollar gain (or % gain) or b) the close of the same day

Exit Order Type: Market
Exit Order Type Price: close
Exit String Contains 1: $daysheld >= 0
Exit String Contains 2: GTCLimit(0.5) // or whatever percentage gain you're looking for

Scenario 2
1) enter trade long at open
2) exit 2 days later at either a) a specified dollar gain (or % gain) or b) the close 2 days later

Exit Order Type: Market
Exit Order Type Price: close
Exit String Contains 1: $daysheld >= 2 // exit at the close 2 days later
Exit String Contains 2: GTCLimit(0.5) // or whatever percentage gain you're looking for

Note: the GTCLimit() will be in place for the entire duration of the position. It is not possible to have the GTCLimit() be in place only after a couple days.

Scenario 3
1) enter trade long at open
2) exit any day later at either a) a specified dollar gain (or % gain) or b) the lowest low within the past 20 days

While it would be programmatically possible to set up both an intraday limit order and an intraday stop order at the same time, your results would not be valid because it would be impossible to tell which side would have exited first (stop or limit) using EOD price bars. Suppose you have a limit exit of 1% and a stop exit at 1%. Then suppose the next day's high/low range was both 2% above the open price and 2% below the open price. Would your 1% limit order be triggered, or your 1% stop order? It is impossible to know, since EOD price bars do not identify whether the day's high price or low price was hit first during the day's trading. It is for this reason that you should not use both intraday limits and intraday stops at the same time when using EOD prices. So Scenario #3 isn't something you can logically test using EOD prices.

Hopefully this helps.

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

Re: How to exit at target amount or close

Postby mandelmus » Sat Dec 22, 2012 2:08 am

Thanks for the quick response.

1) I noticed that, in the other thread, it was mentioned that the chart does not accurately reflect entries and exits when they happen on the same day, is that always the case?

2) I entered the following into the "Exit String" ... "GTCLimit(2) or $daysheld >= 0" ... but it was still exiting some trades up to 6 days later ... how should I enter this to be sure to exit at the end of the same day (i.e., $daysheld = 0)?

3) Related to my previous post,
a) how do we set up a strategy that enters at the open every day and exits at the close of that same day?
b) how do we set up a strategy that enters at the open every day and exits at the close 1 day later?

4) I have seen strategies use "1=1" or "2=2" or "1+1" in the exit string ... when do we use these?

*Note: Trade Settings > General tab > "Allow Re-Entry of Trades on Day of Exit" is checked
mandelmus
 
Posts: 141
Joined: Fri Dec 23, 2011 1:51 pm

Re: How to exit at target amount or close

Postby Overload » Sun Dec 23, 2012 11:45 am

1) I noticed that, in the other thread, it was mentioned that the chart does not accurately reflect entries and exits when they happen on the same day, is that always the case?

That is correct. If you use a market order of "close" for the exit price, it only changes the price at which the position will be exited. But it does not change the day.

2) I entered the following into the "Exit String" ... "GTCLimit(2) or $daysheld >= 0" ... but it was still exiting some trades up to 6 days later ... how should I enter this to be sure to exit at the end of the same day (i.e., $daysheld = 0)?

Do you have any other exit rules being used? If $daysheld >= 0 is not joined with other rules, then you should be exiting at the next day.

3) Related to my previous post,
a) how do we set up a strategy that enters at the open every day and exits at the close of that same day?

See Scenario 1 from the earlier post for information on how to do that.

b) how do we set up a strategy that enters at the open every day and exits at the close 1 day later?

Scenario 1 or 2 will show how to do that, but you can adjust the $daysheld evaluation to the number of days you want.

4) I have seen strategies use "1=1" or "2=2" or "1+1" in the exit string ... when do we use these?

Something like 1=1 can be placed in an Entry or Exit String to force an "always on" trading rule. Depending on what else you're doing with the strategy, that can be a helpful tool. But you must also make sure that it interacts with the other rules in the way that you want. In other words, using 1=1 doesn't necessarily mean that the signal will be triggered every time. It depends on the other rules.

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

Re: How to exit at target amount or close

Postby mandelmus » Wed Dec 26, 2012 2:53 am

I still can't get SS to enter long every single day and exit the same day. I have tried several combinations of settings with no luck and need some guidance. Here is what I have:

> Entry String: 1=1
> Exit String: GTCLimit(2) or $daysheld = 0

> Rank Settings: Select Symbols Alphabetically
*(note: I am using a custom sector with only 1 stock symbol to test this strategy)

> Entry Order Type: Market
> Entry Order Price: ref(open,1)

> Exit Order Type: Market
> Exit Order Price: close

I want the strategy to enter LONG every morning at the open and exit every afternoon at the close, with no other criteria. With the versions I have tried, some trades are in for 1+ days before exiting. Did I mess up some system-wide settings that are preventing my strategies from working properly?

Also, I noticed that when I select a portfolio size of 1 (in the Detailed Analysis), only 1 trade is displayed. I have to set portfolio size to 2 or more in order to get more trades. Why is that?
Last edited by mandelmus on Sat Dec 29, 2012 5:00 am, edited 1 time in total.
mandelmus
 
Posts: 141
Joined: Fri Dec 23, 2011 1:51 pm

Re: How to exit at target amount or close

Postby Overload » Wed Dec 26, 2012 9:34 am

Here are a couple things:

1) For your exit string, make sure you use: $daysheld >= 0 instead of just $daysheld = 0. I haven't tested if this will help, but it's always best to do a "catch all".

2) As mentioned in the other thread, if you do not use one of the intraday stops (GTC or stop/limit orders), the date of the exit will be the next day regardless and the Days Held will be 1. But if you check the Close price, you will see that it does indeed exit on the close price of the day the trade was entered. You should check this to verify.

If it's still a problem after this, you an package up the strategy using the File > Export Database menu and send me a copy at support@stratasearch.com. I can then run it and help identify other issues.

Also, I noticed that when I select a portfolio size of 1 (in the Detailed Analysis), only 1 trade is displayed. I have to set portfolio size to 2 or more in order to get more trades. Why is that?

Using Fixed or Variable Trade Equity, you cannot enter additional trades if you don't have enough cash to make those trades. With a Portfolio Size of 1, if you lose money on the first trade, there won't be enough money to make additional trades. Viewing the Variable Trade Equity, you can usually keep "trading" even with one losing trade.

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

Green button continues flashing after processing

Postby mandelmus » Sat Dec 29, 2012 5:17 am

I noticed that when I run a very simple strategy on a single symbol with no optimizable variables (like the one posted above), the green "processing" button continues flashing for a few minutes even after the strategy appears to have finished. Is that supposed to happen or should it stop flashing immediately after running the strategy?
mandelmus
 
Posts: 141
Joined: Fri Dec 23, 2011 1:51 pm

Re: How to exit at target amount or close

Postby Overload » Sat Dec 29, 2012 10:20 am

The green light will be flashing as long as the Processor is not idle. When it becomes idle, it should revert back to being solid green.

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


Return to Technical Support

cron