October 16, 2019

Exiting using limit orders

Most of us focus our research time looking to find better entries. We don’t spend enough time thinking about our exits. I am definitely guilty of this. A popular way to enter a mean reversion trade is by using a limit order. I use that on the strategy on RSI2 Strategy: Double returns with a simple rule change post.

The exit on that strategy is on the open. Many people don’t like exiting on the open because of the volatility and the belief that you will get a bad fill. What if we exit instead using limit orders? I tested this idea years ago. Time to revisit an old idea.

Just because the limit price gets touch or exceeded does not guarantee we will exit or fully exit in real trading. We must live with that issue for these tests.

The Initial Strategy

Test range from 1/1/2007 to 9/30/2019.

Set up Rules

  1. Stock was a member of the Russell 3000 index, is not currently a member of the index
  2. Stock is traded a major exchange.
  3. The as traded price is greater than $1
  4. The 21-day moving average of close*volume greater than $500K
  5. Close is greater than the 100-day moving average
  6. Two period RSI is less than 10

Entry Rules

  • If we have a set up, then enter a limit order for the next day at 5% below the close. Order good for one day only.
  • Only place enough orders so if they are all filled you are not in over 10 positions
  • If have multiple set ups, then rank from high to low by the 100-day historical volatility.

Exit Rules

  • Two period RSI is greater than 50 or after 10 trading days
  • Exit on next open

Simple mean reversion exit of waiting for the bounce.

Base Results

These are the results we will compare against.

The Limit Exit

The exit rule will now be changed to:

Exit Rules

  • If RSI is greater than 50 at the close, place a limit order to close the position [.5,1,1.5,2]% above the close
  • Order is good for one day only

OR

  • After 10 trading days
  • Exit on next open

 

Limit Exit Results

A small change in the numbers. Not sure what I was expecting. For a little piece of mind of not having to deal with the open, this is an interesting way to get out.

Limit Exit with Lower RSI

Instead of waiting until the RSI2 is above 50 to place the limit order. What if we changed that to 30?

Now all the results are slightly better than the original test.  CAR, Avg % p/l, % winners are all up with average hold down.

Spreadsheet

Fill in the form below to get the spreadsheet with lots of additional information. This includes more RSI exit values and limit values than shown. See the results of all variations from the optimization run. This includes top drawdowns, trade statistics and more.

Final Thoughts

I will have to try this on my mean reversion strategies I trade. I like that for small percent exits most the stats I care about improved some.

There are two issues. Just because the limit price is touched or exceeded does not guarantee you will get out of the position or you may get a partial fill. These are always annoying to deal with.

Then comes the possible psychological problem of trading this. What if the stock is up big, then you place the order to get out but then it turns around and craters? I will have to look at any trade lists to see how often this happens.

Backtesting platform used: AmiBroker. Data provider: Norgate Data (referral link)

Good quant trading,

Fill in for free spreadsheet:

spreadsheeticon

 
Visited 55 times, 1 visit(s) today

Click Here to Leave a Comment Below

Craig Peters - October 16, 2019 Reply

Hi Cesar

Great post and pleased to see that you’ve seen similar slight improvements in your numbers when implementing limit exits. I think the biggest positive for me wasn’t the performance but rather the closer replication of actual exit fill prices compared to back tests.

Your point about limits not being filled, even though a high may have exceeded it, is a great one. I’ve been trading a variant of this strategy for well over a year now, and I’ve found a particular OHLC configuration where non-fills tend to be acute.

For slightly illiquid stocks, where the opening price represents the exact high of the day, I’ve found that I can get a lot of non-fills because my limit order doesn’t participate in the morning auction and the market is so thin that the next trade price is way below my limit (and remains there for the rest of the day).

It was leading to such differences between live and testing that I ended up having to do two things:
1. I tightened up my stock universe filter to exclude more of the illiquid-looking stocks.
2. Added a prudence measure to the simulation, such that if the open=high and high>limit price, I would not assume a fill (unless the close>limit price).

The latter measure did have an effect on simulation performance but not too adversely.
My live results have been mirroring simulation much more closely since making these changes in May.

Best Regards
Craig

    Cesar Alvarez - October 16, 2019 Reply

    Glad you liked the post. When testing illiquid stocks, I too do not take the fill when Open = Low (for long systems). I wanted to show another way of getting out besides the open. One could exit half at the open and the other half at the limit. Thus spreading the shares out on illiquid stocks.

Mark - October 27, 2019 Reply

Hi Cesar,

Why wouldn’t you exit on the Close and remove the exposure to the overnight risk that the stock may gap lower?

Mark

    Cesar Alvarez - October 28, 2019 Reply

    Exiting at the close vs the open is not necessarily better in terms of performance. Depending on the exit rule, one may not know until right before the close if there is an exit. That means having to be in front of the computer at the market close. That is not how I want to trade. And then there is the issue is the actual close price may be different than your exit price and you should not have exited. Which then causes other issues on what now to do.

    For my own trading, I do not trade at the close and that is why I rarely write about exiting at the close.

Mark - October 29, 2019 Reply

Thank you for the response. I have a few comments on the points raised:

1. Close vs Open performance – Although the back tested performance difference may be indifferent between the 2 options, trading on the Close removes the risk that you get a signal to exit only for the stock to gap against you the next morning. This may well balance out over time with when the stock gaps in your favor but my belief is that as the exit signal is based on the Close; exiting the trade on the Close will lead to more consistent results. Certainly less frustration anyway, as you just can’t know what the price will be on the Open. Maybe just my trading preference.

2. Needing to be in-front of the computer to exit on the Close – This isn’t the case. With a simple exit rule such as RSI, it is possible to rework the formula to calculate what the closing price would need to be for RSI to be beyond, say 50. It’s straight forward to calculate this for all open positions and then place Limit-On-Close orders outside market hours, to take you out of the trade if the price is reached or exceeded on the Close the next day. Obviously when a N-Day exit rule is reached a Market-On-Close order would be placed.

3. Actual Close differing from Exit Price – My experience has been that the Close is the most reliable price of the day. I used to religiously compare the price i exited at with the price in my data service (Norgate). I stopped doing so as it never differed.

    Cesar Alvarez - October 29, 2019 Reply

    1. It is a trading preference. I have tested both exiting at the close and open. Overall it tends to have little difference in my strategies. But on a particular year it may have a ‘large’ difference.
    2. It depends on your rules whether this is possible or not. I have built a reverse-RSI calculator and know it is possible.
    3. This is the point I was not clear on. Your exit price may not be the actual close price because say of a last second tick down. Now you may have exited at 23.12 which what stratgy said to exit at but the close was 23.10. Which now your strategy says you should not have exited. Now you are out of a position that your strategy says you should be in.

Leave a Reply: