April 26


What 567,000 Backtests Taught Me About Algo Trading Exits

By Kevin Davey

April 26, 2021

Ask any trader how they trade, and 8 times out of 10 the answer will involve the entries they use to trade:
“When the trendline is confirmed, I enter.”

“When the close is above the 9 bar moving average and the RSI is not oversold, I go long.”

“When the order flow suggests a downwards push, I go short.”


If you need any more proof of the popularity of entries, just look at trading videos on YouTube. Most of them are focused on entries. Even my You Tube channel, which hits on a variety of trading topics, has entry videos as its most popular selections.

"Many times exits are even more important than entries!"

But entries are only part of the story. Money management, psychology, and position sizing all play a role. And, of course, exits. Many times exits are even more important than entries!

So, to give exits their long deserved recognition, I am going to study a variety of them, with some fairly standard entries. Which exit is the best? That is what I hope to determine in this study.
What Exits Should I Choose?

If you have read any of my previous research, you know I favor simplicity over complexity. My experience is simple strategies tend to hold up better over time than complicated, multi-variable strategies. Therefore, to get a wide range of exits, I am going to examine some "simple" ones, some “intermediate” level exits, and some "complicated" exits:

Simple Exits
1. Stop & Reverse Exit
2. Time Based Exit
3. Dollar Stop Loss
4. Dollar Profit Target
5. Dollar Stop With Profit Target
6. Average True Range Stop Loss
7. Average True Range Profit Target
8. Average True Range Stop With Profit Target
Intermediate Exits
9. Trailing Stop
10. Breakeven Stop

Complicated Exits
11. Parabolic Stop
12. Chandelier Stop
13. Yo-Yo Stop
14. Channel Exit
15. Moving Average Exit
Each of these exits will be described in a later section. For each exit, I will run 9 different combinations of the exit parameter or parameters.

I should point out I do NOT use market on close MOC orders in this study. Why not? Here's a discussion of the pitfalls with Market On Close MOC orders.
Entries, Markets, And Everything Else

I’ll test each of the 15 exits with 5 unique entries (Tradestation code shown):
1. Simple Momentum Entry
  If close>close[InputVar2] then buy next bar at market;
  If close<close[InputVar2] then sell short next bar at market;

2. Breakout Next Bar Entry
  If high=highest(high,InputVar2) then buy next bar at market;
  If low=lowest(low,InputVar2) then sell short next bar at market;

3. Single Moving Average Cross Entry
  If close crosses above average(close,InputVar2) then buy next bar at market;
  If close crosses below average(close,InputVar2) then sell short next bar at market;

4. Bollinger Band Entry
  If close crosses above BollingerBand( close, InputVar2, -2) then buy next bar at market;
  If close crosses below BollingerBand( close, InputVar2, +2) then sell short next bar at market;

5. Volatility Entry
  If Close> close[1] + AvgTrueRange( InputVar2 ) * 1.5  then  buy next bar at market;
  If Close< close[1] - AvgTrueRange( InputVar2 ) * 1.5  then  sellshort next bar at market;

Note that there is one input to optimize for the entry, the input “InputVar2.”  This is a lookback length, and for the study I will vary this from 15 to 35 in steps of 10.
I am going to test the exits on 40 different futures markets (Tradestation continuous contract symbols shown).

@AD, @BP, @CD, @DX, @EC, @JY, @SF

@BO, @C, @CC, @CT, @FC, @KC, @KW, @LC, @LH, @O, @OJ, @RR, @S, @SB, @SM, @W

@GC, @HG, @PL, @SI

@CL, @HO, @NG, @RB

Interest Rates
@FV, @TY, @US

Stock Indices
@ES.D (day session),@ES, @NK, @NQ, @RTY, @YM

"How Do You Determine What The Best Result Is?"

Bar Sizes
Since results can vary dramatically depending on the size of the bar that is tested, I will test 5 different bar sizes:

1,440-minute (daily)

Test Period
I will run all cases thru 10 years of historical data, from January 1, 2010 to January 1, 2020.

Other Test Criteria
As always, I will include proper amounts for slippage and commission in the study. Each market has its own value for slippage, based upon its liquidity and volume. I’ll use values that I have determined from real money trading, and also from in-depth analysis of bid-ask prices.

For some of the exits, the use of “Look Inside Bar Backtesting - LIBB” is necessary to get accurate results. If you do not know what LIBB is, or why it is important, check out this video, starting at 8:02: https://youtu.be/tNWdJeHRZNE?t=482

How To Compare Results
Of course, when comparing 567,000 tests, the question “how do you determine what is best?” will inevitably come up. I am going to look at 2 different metrics:

Return on Account = Total Net Profit / Maximum Drawdown (shown in charts and tables as “Average of Return On Account”)

# of Cases With Net Profit > $25K = High Net Profit Cases (shown in charts and tables as “Sum of Prof > $25K”)

Of course, I could write a whole article on why I chose these particular metrics, and someone could counter with reasons why other performance metrics would be better.

My goal here was to compare risk adjusted returns, and also to identify which combinations produced a “good” overall Net Profit. My personal experience is that when both of these metrics are mediocre, chances are the strategy entry and exit just are not that good.
Summary Of Testing
40 markets x 5 Bar Sizes x 5 Entries x 3 Lengths per Entry x 15 Exits x 9 Settings Per Exit = 405,000 Unique Tests (later on in Part 5 I will add in more exits to the study, which will increase the test total to 567,000)

If you work with Tradestation at all, you’ll soon realize that all of this testing would be very tedious and time consuming!

Luckily, I have a great helper tool. It is called Multi-Opt, and it automates a lot of the testing process. So, for example, you do not have to run unique optimizations on every market and bar size. Multi-Opt uses Tradestation’s OOEL (Object Oriented Easy Language) and the Tradestation Optimization API to speed the process up.

Unfortunately, Multi-Opt is not available to the general public, but luckily it is available exclusively to students of my Strategy Factory workshop.

Even with Multi-Opt to speed up the testing, running all the cases actually took over 100 hours of non-stop testing, even after utilizing multi-threading.

"ALWAYS verify results with your own testing/analysis"

I’ll be showing the results I obtained from this testing; if you run tests yourself, you may get different results, and therefore reach different conclusions. You may program entries and exits differently than I did, or you may use different ranges for variables than I did.

And just because Exit A is better overall than Exit B with average performance metrics, it does not mean it is always better. Maybe certain markets or bar sizes work better with Exit B than Exit A, for example.

The point here is that you can use the results I found to guide your research in testing, but ALWAYS verify results with your own testing/analysis. At the end of the day, you are going to be the person trading your account, so you should also be the person testing your particular strategies.

That being said, this study can be a huge time saver for you. For instance, why bother testing systems with the worst exit? Focus on the good results first!

Baseline (Stop & Reverse) Exit Results, and Time Based Exit Results
Stop & Reverse

It might seem like the Tradestation Easy Language code:

If close>close[InputVar2] then buy next bar at market;
If close<close[InputVar2] then sell short next bar at market;

has no exit at all, but that is not the case. With Tradestation, a “buy” comment means 2 things. First, any short is exited. Second, a long position is initiated. Vice versa for short trades. Thus, these standard buy/sell short keywords are stop and reverse commands.
For the Stop & Reverse Exit case, that is the only exit – a reverse in position. These strategies are then, by definition, always in the market.
I should point out for this study that all exit cases include stop and reverse built in. That is because of the code show above. As mentioned previously, this code will reverse an existing position. And that is what I used for all the cases I am running.
As an alternative (I’ll leave the reader to test this), I could have run entry code like this:

If mp=0 and close>close[InputVar2] then buy next bar at market;
If mp=0 close<close[InputVar2] then sell short next bar at market;

“mp” refers to marketposition, so with the code above, the entries are only activated if the current position is flat. There is no stop and reverse for this code.

If you try such code, just remember to have other exits in the strategy; otherwise the strategy may enter a position and never exit!
Time Based Exit

If the trader assumes an entry signal will be “good” only for a certain number of bars, exiting after a certain number of bars makes a lot of sense. It has been said that legendary trader, John Henry favors this type of exit.

In Tradestation, the code looks like this:

  If MP=1 and BarsSinceEntry>InputVar4*5 then sell next bar market; //exit long trades
  If MP=-1 and BarsSinceEntry>InputVar4*5 then buytocover next bar market;  //exit short trades

I’ve set up InputVar4 to vary from 1 to 9, so with this exit, the strategy will stay in the trade for 5 to 45 bars after entry.
Now on to the results…
With all the data, the results are pretty clear: Stop & Reverse Exits are much better than Time Based Exits.

Stop & Reverse Exits provide a higher Avg Return on Account, and produce more “highly profitable” cases (after adjusting for the fact that Stop and Reverse Exits have only one exit value, while Time Based Exits have 9 values).
The other interesting thing to note is that overall, both exits lose money over the 10-year test, on average. Of course, a lot of that could be due to the markets chosen, the entries, and the bar sizes.
Let’s see what breaking down the data a bit further looks like…
By Market Sector

When viewed by market sector, Stop & Reverse is always better than the Time Based Exit. And the only sectors, on average, that make money are Metals and the Stock Indices. This could be because of the trendiness of those sectors, as compared to other sectors.

By Bar Size
Many algo traders (myself included) will tell you that bigger chart bar sizes tend to be better for trading systems. Whether this is due to reduced noise in the larger bar sizes, or possibly getting further from the realm of high frequency trading firms, all other things being equal, daily bars are more profitable than 60 minute bars.

As shown in the tables below, the worst results are with the shortest bar – the 60-minute bars. The best bars are actually 720-minute (12 hours), followed by 1,440-minute bars.

By Entry Type
I’ve previously done separate studies on entries before, and the conclusion was that breakout entries were superior to other common entries.
Results for this study confirm those earlier results. 

Best entries for Stop & Reverse Exit:

1. Breakout
2. Bollinger Bands
3. Volatility Break
4. Momentum
5. Moving Average Cross

Best entries for Time Based Exit:

1. Bollinger Bands
2. Volatility Break
3. Breakout
4. Moving Average Cross
5. Momentum

For both exits, the top 3 entries were Bollinger Bands, Volatility Break, and Breakout. And for 4 of the 5 entries, the Stop & Reverse Exit was better than the Time Based Exit.

By Entry Lookback Length
For each of the 5 entries, there is a lookback length for the calculation. I chose 15, 25, and 35 bars for the lookback, since this roughly corresponds to a short, medium, and long term length.

These lookback lengths are not really all that different though. I probably should have tried 5, 50, and 100, or 200 bars for lookback. Oh well! Results for these three lookbacks are similar, although the more responsive shorter lengths are better.

By Exit Parameter Value
Since Stop & Reverse has no exit parameter, the results will be the same for each value. For the Time Based Exits, the values shown in the tables below should be multiplied by 5 to convert to "number of bars to exit after".

The results show again that Stop & Reverse Exits are always better than time based exits. Also of note it that quick time based exits (5 bars) are, as a whole, much worse than 45 bar exits.

Conclusion – Stop & Reverse Vs. Time Based Exits

From this study, it is pretty clear that the Stop & Reverse is a better exit than the Time Based Exit, regardless of the market sector, bar size or practically any other parameter.

Of course, that does not mean Time Based Exits should be discarded, but it is good to know that many times they might just add system complexity without adding any real value.

Quick Takeaway, Part 1:

First Try Stop & Reverse Exits, Before Adding in Time Based Exits

Part 2 – Other Simple Exits

In this section I’ll look at 6 relatively simple exits – can any of these outperform the Stop & Reverse Exit?

First, I’ll start with dollar-based stops and targets. In another study I did, I showed that many times ATR stops were better than Dollar stops. But this is a different study, and we will see if we reach different conclusions.
For all testing, the input “InputVar4” runs from 1 to 9. So, the stop values in dollars per contract will run from $500 to $4,500. Profit targets will run from $1,000 to $9,000. Finally for the value of InputVar=9, there is no stop loss or profit target.
Dollar Stop
Pretty much as simple as it gets. Having just this exit will let profits run until the reverse entry takes you out. No limit on potential profit.

SetStopLoss(InputVar4*500);  //Dollar Stop Exit

Dollar Target
This profit target uses a limit order, so you should check to make sure that your platform will fill limit orders only if the limit price is exceeded. This exit alone can be dangerous, as you are looking for the reverse entry to exit any bad trades. The loss on a trade could be significant. On the flipside, you are limiting your profit by having a target, which may not turn out to be a good idea.
SetProfitTarget(InputVar4*1000);  //Dollar Target Exit
Dollar Stop Loss and Dollar Target

This exit has both a stop loss and a profit target. I have arbitrarily picked the profit level to be 2x the stop level. This obviously could be something that is optimized – maybe I’ll do a study of that in the future…
SetStopLoss(InputVar4*500);  //Dollar Stop Exit
SetProfitTarget(InputVar4*1000);  //Dollar Target Exit

Earlier I referenced an earlier study I did on stop losses. If you want the "condensed" version, just watch this video:

Average True Range Exits
ATR Stop
ATR-based exits are calculated using the 14-bar Average True Range. No limit on potential profit.

ATR Target
This profit target uses a limit order, so you should check to make sure that your platform will fill limit orders only if the limit price is exceeded. This exit alone can be dangerous, as you are looking for the reverse entry to exit any bad trades. The loss on a trade could be significant. On the flipside, you are limiting your profit by having a target, which may not turn out to be a good idea.

ATR Stop Loss and Dollar Target
This exit has both a stop loss and a profit target. I have arbitrarily picked the profit level to be 2x the stop level. This obviously could be something that is optimized – maybe I’ll do a study of that in the future…

Overall Results

Results can be summarized as follows:

Stop and Reverse Exit is still the best.
Dollar-based exits are generally better than ATR exits.
Target exits are generally better than stop exits.
Of all 3 combinations (stop, target or stop/target), the stop/target is always the worst.
The findings here are generally inline with the results of an earlier study I did. In that study, I found stop and reverse (“no exit” in earlier study) was the best, and ATR was a bit better than dollar exits (this study shows dollar exits are a bit better). This could be because of different strategies used, different performance metrics, etc.

I think the major takeaway is that the Stop & Reverse Exit still reigns supreme!

By Market Sector

For just about every market sector, Stop & Reverse is the winner. Second best is the Dollar Target exit. This flies in the face of the common market adage, “let your profits run.” Maybe you only let your profits run up to a point. Interesting!

By Bar Size

Bar size analysis leads you to Stop & Reverse with 1,440-minute bars as being the best.

By Entry Type

Maybe some entries work best with certain exits. What does the data tell us?

Once again, for the most part, Stop & Reverse exits are the best.
Quick Takeaway, Part 2:

First Try Stop & Reverse Exits, Then Try Dollar Target Exits
Maybe more complicated exits can beat out Stop & Reverse. I’ll examine that in Part 3.

Part 3 - More Complicated Exits

Looking at the results so far, the simplest of simple exits - the Stop & Reverse Exit - is the clear winner. The video below discusses the first two parts of this article, and adds some additional analysis:

In this section, I’ll take a look at some complicated exits. More complicated exits are usually a double edged sword. Many times these exits have more parameters to “tune,” which is great for creating backtests, but not necessarily great for real time performance. Remember, the more parameters to optimize, the greater the chances of curvefitting.
Trailing Exit

The trailing exit is simply an exit that trails below long positions, and vice versa for short.

//trailing stop
If marketposition=1 and openpositionprofit<maxpositionprofit-InputVar4*500 then sell next bar at market;
If marketposition=-1 and openpositionprofit<maxpositionprofit-InputVar4*500 then buytocover next bar at market;

where InputVar4*500 is the dollar amount you want to trail. Note this is not a stop order, but rather a market order that gets placed at next bar open.

The way I've written it, the condition is checked at the end of every bar. Note that maxpositionprofit is a Tradestation keyword, and it calculates the maximum profit at any point during the bar.

You could convert this exit to a stop order if you wanted to.

So let's say you had InputVar4=5. That means the trailing level is 5*500= $2,500 per contract.

If maxpositionprofit never goes above $0, then when openpositionprofit drops below -2,500, you will get an exit signal.

If maxpositionprofit hits $4,000, then when openpositionprofit drops below 1,500, you will get exit signal.

Breakeven Exit

A breakeven exit is pretty simple – when the profit reaches a certain point, if the profit goes back to $0, the position is exited. This is executed using a simple Tradestation keyword:


Parabolic Exit
Chandelier Exit
Yo-Yo Exit

The Parabolic, Chandelier and Yo-Yo stops are all fairly complicated exits. I won’t explain them in detail here – there are plenty of good resources if you want to learn about them:

Parabolic - https://www.investopedia.com/terms/p/parabolicindicator.asp
Chandelier - https://corporatefinanceinstitute.com/resources/knowledge/trading-investing/chandelier-exit/
Yo-Yo Exit – I could not find a good explanation of this stop, but here is a nice graphic (courtesy of Chuck LeBeau)

Overall Results

So let's see how these 5 complicated exits perform, compared to our baseline (and current champion) Stop & Reverse Exit. Remember, the Stop & Reverse is in all the strategies, so it will not be taken place by complicated exits, but will hopefully exit at more appropriate times than it does.

Results for these more complicated exits are grouped into 3 categories. First, there is the “good” group, which has a single constituent - the Breakeven Exit. It is not much worse than the Stop & Reverse Exit. The next group has the Trailing Exit and the Parabolic Exit, with performance definitely a step down from the Breakeven Exit. The Chandelier Exit and Yo-Yo Exit are in the worst performing group.

These different levels of performance (good, average, poor) can also be seen in a comparison chart of all the exits so far:

Results can be summarized as follows:

Stop & Reverse Exit is still the best.
Breakeven Stops are almost as good as Stop & Reverse.

These results hold true regardless of market sector (Stop & Reverse and Breakeven are always the best two), bar size or entry. The results and conclusions are pretty consistent.
One other interesting note here is that the smaller breakeven stop thresholds ($500 - $1,000) tend to perform better. But overall the Stop & Reverse still is better than the Breakeven stop.

Can anything beat the Stop & Reverse Exit?!?!?! 

Once again, for the most part, Stop & Reverse exits are the best.
Quick Takeaway, Part 3:

First Try Stop & Reverse Exits, Then Try Breakeven Exits

Up until this point, all the exits used have been based in part on the entry signal. The stop I have examined are based on dollars and ATRs, and use the trade entry price or bar to determine the actual level.
What about exits that did not care about the trade entry? In other words, exits based on their own calculations. Can they beat out Stop & Reverse? I’ll examine that in Part 4.

Part 4 - 2 Technical Indicator Type Exits

For all the exits so far (except for Stop & Reverse and Yo-Yo), the exits were tied in some way to the entry price. The Breakeven stop, for example, is set based on the entry price, and the profit and loss from that point. So are all the dollar and ATR stops and targets. And the parabolic and chandelier stops, while incorporating price action in them, are still based on the conditions when the trade begins.

Well, maybe the best time to exit has no relationship to when you enter. Possibly, a good exit can be determined based on analysis of price itself - simple technical levels, indicators, etc. Many traders use support and resistance lines, for example, to exit.

Of course, looking at technical indicators for exiting opens the door to an unlimited array of exits - every entry you can think of could instead function purely as an exit.

Back in 2017, I hosted a weekend retreat for an advanced group of traders in Cleveland, Ohio. One of the things we did was build entries and exits as a group. And one of the findings was that "entries as exits" worked pretty well - usually better than standard run of the mill stops.

This short video explains the concept a bit better:

For this section, I’ll try two simple and popular, yet usually effective, exits based on technical indicators/price action.:
Channel Exit

Simply exit long positions on the next bar if the lowest low of the last X bars is hit. Vice versa for short positions.

Moving Average Exit

When in a long position, if the close crosses below the X bar moving average, exit the long position. Vice versa for short.

I chose these 2 "entries as exits" because they are pretty common, and easy to implement. Obviously, I just scratched the surface with this concept, so I'll leave it to the reader to take the next steps with the idea.

Overall Results


These exits are nowhere near as good as Stop & Reverse. So, rather than bore you with details of the results, I’ll just stop here. The Channel & Moving Average Exits - at least how I tested them - are not that good.
Here are the results for Return on Account and Cases With Profit > $25K, for all 15 of the tested exits.

This has been an interesting study so far, but also a bit depressing. I thought for sure something - anything! - would beat the simple Stop & Reverse Exit. Yet nothing has!

Maybe my results are a fluke, a testament to keeping strategies simple. Maybe you'll get different results in your testing (I highly encourage you to try).
Quick Takeaway, Part 4:

Stop & Reverse Exits Still The Best!

Part 5 - Combination Exits

OK, I'll admit it - I am a bit bummed about the findings so far. Sure, back in Part 1 I found that Stop & Reverse Exits were the best, but I felt for sure one of the other 14 exits I tried would do better.

Yet nothing has topped Stop & Reverse yet! And keep in mind, that is across multiple market sectors, bar sizes, entries, and entry parameter settings. In almost all cases - and certainly overall as a whole - Stop & Reverse is the clear winner.

Up to this point, the top four exits for Average Return on Account look like this:

Maybe a combination exit would improve performance. For example, having a Dollar Target with a Breakeven Exit, or a Dollar Target with A Trailing Exit.

I will test six of these combination exits:

Dollar Target with Breakeven Exit
Dollar Target with Trailing Exit
Dollar Stop with Breakeven Exit
Dollar Stop with Trailing Exit
Dollar Stop/Target with Breakeven Exit
Dollar Stop/Target with Trailing Exit


The combination exits are shown highlighted in the tables below.

So, none of the combinations improve upon the simpler single exits. This is a bit disappointing!

The study has done a lot of testing, and what have we found? Stop & Reverse Exits – pretty much the simplest exit possible – turns out to be the best. This is pretty much true across different market sectors, different bar sizes and different entries.

After seeing all the data, I REALLY want something to beat simple Stop & Reverse. While I was thinking of ideas, I was chatting with my Strategy Factory student, Rogerio from Brazil. He attended my workshop a few years ago, and still developing systems the Strategy factory way (nice!).

Anyhow, in chatting with Rogerio, I thought of this variation:

Stop & Reverse With a Dead Zone (Hysteresis) 

With a normal Stop & Reverse, you are always in, Long or Short:

If high=highest(high,InputVar2) then buy next bar at market;
  If low=lowest(low,InputVar2) then sell short next bar at market;

After talking with Rogerio, I thought "what if I front run that reverse, and exit earlier?" Would that make a difference?

Something like this:

 If high=highest(high,InputVar2) then buy next bar at market;
 If low=lowest(low,InputVar2) then sell short next bar at market;

 If marketposition=-1 and high=highest(high,InputVar2-5) then buytocover next bar at market;
 If marketposition=1 and  low=lowest(low,InputVar2-5) then sell next bar at market;

I arbitrarily selected a 5 bar "front run" - maybe something shorter will be better, maybe something longer.

For each entry, I included this new "dead zone" feature. Here are the results...


I ran the test with the three best exits: Stop & Reverse, Dollar Target, and Breakeven. Those results are in the column "Average of Return on Account" - nothing new here, they were discussed earlier.

Then, I ran those same three cases with the Early/Fast Stop option, as described above. These results are in the column "Average of Return on Account with Fast Stop (no Reverse)." These are the new results.

As you can see below, in each case the results are WORSE with the new exit.

Just to confirm the results were not a fluke, I decided to look at each individual entry - maybe some entries like this early exit option, while some do not.


So, based on this study, trying to "front run" the standard Stop & Reverse Exit is not a worthwhile pursuit.


What has this study taught us?

Stop & Reverse Exits are the best

Dollar Target Exits and Breakeven Exits are runners up – close to, but not as good as, performance of Stop & Reverse

No Exit generates profit across all market sectors, bar sizes, and entry method

That is what I found, in a pretty comprehensive research project. But, could you do the test yourself, and find something different? ABSOLUTELY! As I explained in the beginning, I made a lot of decisions about how and what to test. If you test something different - maybe use different entries, for example - then you might reach completely different conclusions.

So while this study might help you avoid certain dead-ends in testing, I HIGHLY RECOMMEND you test things for yourself. That is what I teach my Strategy Factory students, and I find they have much more confidence in their own trading because of it!

How I Plan On Using Results
Stop and Reverse will always be the first thing I test.  Next, I'll look at Dollar Target exits, followed by Breakeven exits.  I will use this as part of my Strategy Factory process, which helps ensure that the risk of curve fitting and over optimization remains low.  If you want to learn more award the Strategy Factory - the process I used to win a Worldwide, Real Money Trading Contest - just visit this link: Strategy Factory Workshop

So, good luck, and happy testing!!!  

Challenge:  Do you think you have an exit that can outperform Stop & Reverse, on the 5 entries, 40 markets, 5 bar sizes and 10 years I tested?  I’d love to hear from you!


1. Send me the code for your exit in Tradestation format (make sure it is verified). The exit has to be ready to go - I will not code it for you. See examples below).
2. Exit can have up to 2 parameters to optimize (you have to give me the ranges to use, and remember I take the average results, not optimum. So your ranges should produce good results not matter the value used.) BIG HELP: The first parameter should be called "InputVar2" and the second one "InputVar4" - if you do that before you submit, it will make my job easier.
3. If you optimize 1 parameter, you can have up to 9 values. If you have 2 parameters to optimize, you can have 3 values for each parameter (9 cases total).  You can have fewer than 9 total values, also.
4. The code has to be fairly simple (in my final judgment).
5. No proprietary or secret formulas allowed, because if it beats Stop & Reverse, I’ll share your code with all readers. So if you want to keep your exit a secret, don’t send it in!
6. Criteria will be “Average Return On Account” - just like I calculated in this study. It has to beat this:

7. One submission per person.
8. Since testing takes a while, I will accept only the first 15 submittals.
9. I will test with LIBB=1 minute.
10. No SetDollarTrailing, SetPercentTrailing or any other exits (in my opinion) which I feel might be tricking the backtest.
11. I will accept the first 15 submittals before December 15th.
12. I am the final judge on all decisions. 
13. Void where prohibited by law.

If your exit outperforms the Stop & Reverse Exit, I’ll send you autographed copies of all 4 of my books.

AND if multiple people submit winning exits, I’ll give the top 3 a $1,500 discount on my Strategy Factory workshop! (Current workshop students are only eligible for the autographed books, not the discount.) 

Finally, for the best exit that beats Stop & Reverse, you will be recognized as the “Exit Champion” and I’ll post your info (if you desire) on my website and social media.


E-mail me your exit code and parameter ranges, in Tradestation Easy Language format. Send it to kdavey@kjtradingsystems.com

My 2 Exit Entries

Here are 2 examples to follow if you are making a submittal:

Exit Challenge Submittal
Catchy Exit Name: PP8175
Name: Kevin Davey
E-Mail: kdavey@kjtradingsystems.com
If this exit wins, I give Kevin the right to publish code and results: Yes


//Inputs, ranges:
//ppfloor1 = 1000 to 3000, step 1000 (3 values)
//ppratio1 = .50 to .70, step .10 (3 values)

//set ppfloor and ppratio values to protect profit

Input: ppfloor1(1000); //don’t invoke exit 1 until $1000 profit level is reached
Var: ppfloor2(0); //don’t invoke exit 2 until ppfloor2 profit level is reached
Var: ppfloor3(0); //don’t invoke exit 3 until ppfloor3 profit level is reached

Var:ppratio(0); //depends on maxpositionprofit

Input:ppratio1(.60); //profit exit 1 keep ratio – keep 60% of maximum profit
Var:ppratio2(0); //profit exit 2 keep ratio – keep ppratio2 of maximum profit
Var:ppratio3(0); //profit exit 3 keep ratio – keep ppratio3 of maximum profit

If maxpositionprofit>=ppfloor1 then ppratio=ppratio1;
If maxpositionprofit>=ppfloor2 then ppratio=ppratio2;
If maxpositionprofit>=ppfloor3 then ppratio=ppratio3;

If maxpositionprofit>=ppfloor1 then begin
  if (openpositionprofit/maxpositionprofit)<ppratio then begin
   if marketposition=1 then Sell next bar at market;
   if marketposition=-1 then Buy To Cover Next bar at market;

Exit Challenge Submittal
Catchy Exit Name: Tradestation SetPercentTrailing Replacement (https://community.tradestation.com/Discussions/Topic_Archive.aspx?Topic_ID=8714#46331)
Name: Kevin Davey
E-Mail: kdavey@kjtradingsystems.com
If this exit wins, I give Kevin the right to publish code and results: Yes


//Inputs, ranges:
//FloorAmt = 500 to 2500, step 1000 (3 values)
//TrailingPct = 20 to 60, step 20 (3 values)

PositionBasis( false ), 
FloorAmt( 1 ), 
TrailingPct( 20 ) ; 
variables:  BSE( 0 ), HH( 0 ), LL( 0 ), HighProfit( 0 ), CalcFloor( 0 ), Trail( 0 ), MyStopPrice( 0 ) ; 
if MarketPosition <> 0 then 
BSE = BarsSinceEntry( 0 ) ; 
CalcFloor = FloorAmt ; 
if PositionBasis then 
HighProfit = MaxPositionProfit( 0 )  
HighProfit = MaxContractProfit( 0 ) ; 
if MarketPosition = 1 then 
HH = Highest( High, BSE ) ; 
if HighProfit >= CalcFloor then 
Trail = (TrailingPct * .01) * ( HH - EntryPrice( 0 ) ) ; 
  MyStopPrice = HH - Trail ; 
if MarketPosition = -1 then 
LL = Lowest( Low, BSE ) ; 
if HighProfit >= CalcFloor then 
Trail = (TrailingPct * .01) * ( EntryPrice( 0 ) - LL ) ; 
  MyStopPrice = LL + Trail ; 
if MarketPosition <> 0 and MaxPositionProfit > FloorAmt and MyStopPrice <> 0 then 
if MarketPosition = 1  then 
Sell ("Alt%Trl LX") Next Bar at MyStopPrice Stop ;  
if MarketPosition = -1 then 
BuytoCover ("Alt%Trl SX") Next Bar at MyStopPrice Stop ;  
end ;

Kevin Davey

About the author

Kevin Davey is a professional trader and a top performing systems developer. Kevin is the author of “Building Algorithmic Trading Systems: A Trader's Journey From Data Mining to Monte Carlo Simulation to Live Trading” (Wiley Trading, 2014.) . He generated triple digit annual returns 148 percent, 107 percent, and 112 percent in three consecutive World Cup of Futures Trading Championships® using algorithmic trading systems.

His web site, www.kjtradingsystems.com, provides trading mentoring, trading signals, and free trading videos and articles. He writes extensively in industry publications such as Futures Magazine and Active Trader and was featured as a “Market Master” in the book The Universal Principles of Successful Trading by Brent Penfold (Wiley, 2010).
Active in social media, Kevin has over 15,000 Twitter followers. An aerospace engineer and MBA by background, he has been an independent trader for over 20 years. Kevin continues to trade full time and develop algorithmic trading strategies.

  • Howard Bandy, in his book, “Mean Reversion Trading Systems – Practical Methods for Swing Trading,” (2013) came to similar conclusions, albeit, with slightly different constraints.

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Learn To Code & Build Strategies
    Using EasyLanguage.