Skip to content
All library documents

Choosing Stop-Loss and Take-Profit Levels with Sequential Evaluation

Article Quant Q&A · Author: Meuchedet

Summary

The document asks how to choose stop-loss and take-profit thresholds from trade outcomes and expected profit estimates. It points to operations research and stochastic processes, and presents differing views: one answer argues that thresholds may be unnecessary if a strategy has a trusted positive drift, while another emphasizes practical capital limits and risk tolerance. A further response recommends evaluating candidate threshold pairs with historical data.

That proposed process divides observations into chronologically ordered training, fitting, and unseen periods. It scores a grid of stop and target levels on training data, selects a candidate using performance metrics, then chooses a fitting-period candidate with similar metric behavior before applying it to the next unseen period. The author suggests repeating this sequence to reduce forward bias and mentions approximate trade-path calculations to speed grid evaluation. These are suggestions rather than demonstrated universal rules: results depend on the chosen metrics, data distribution, threshold grid, and assumptions, and the document offers no comparative validation.

Key ideas

  • Stop-loss and take-profit selection can be framed as an operations research problem.
  • A proposed evaluation uses separate chronological training, fitting, and unseen periods.
  • Candidate threshold pairs can be scored on several performance measures and selected sequentially.
  • The discussion gives conflicting theoretical views and does not establish a universally optimal threshold.

Tags

Full text
# Optimization of Take-Profit and Stop-Loss


# Optimization of Take-Profit and Stop-Loss












Three questions:

- What branch of mathematics would help me optimize profit if I have a trading strategy that on an individual trade basis (Trade 1, Trade 2, ..., Trade N) has a draw down of (X1,X2,...Xn) ticks and a profit for each trade of (Y1,Y2,..., Yn) ticks? Maybe I should have a larger stop-loss and smaller take-profit to maximize win percentage or maybe I should take smaller losses and bigger gains? I'm asking assuming I have specific data for X and Y values.

- Now that I know which branch of mathematics I would need to know, what is the formula or algorithm to determine the stop-loss and take-profit that I should use each time?

- What is the answer to questions 1 and 2 if I would want to know how to include in an algorithm or formula a potential Take-Profit that I come up with for each trade. For example, let's say that I project that for Trade 1 the potential profit is P1 and for Trade N the potential profit is Pn. Maybe the algorithm will say to ignore that piece of information and take Z ticks each time or maybe the algorithm will dictate a better actual-Take-Profit value if I include in that algorithm what I think my profit could be.

## Answer by Jacques Joubert (score 4)

https://quant.stackexchange.com/a/46992

To answer question one: Operations Research would help you with this topic.

Updated:

Stochastic Processes is also a good course to take.

There is a very good paper titled: Determining Optimal Trading Rules without Backtesting

It shows how to determine TP and SL levels using synthetic data.

## Answer by elemolotiv (score 1)

https://quant.stackexchange.com/a/54349

the way I see it, there isn't much to optimise about stoploss/takeprofit for the following simple reasoning:

- imagine you devised a trade strategy that on average builds up profit

- you can think of your trades as random walks with positive drift. That is, you can break each trade into a series of steps (e.g. steps of 1 minute duration). Each step yields a little profit distributed like $N(\mu,\sigma^2)$, with $\mu>0$. All steps add up into your overall trade profit. So after $n$ steps your trade profit is distributed like $N(n \mu,n \sigma^2 )$. Basic math, does this make sense?

- now, your trade profit after $n$ steps will be $n \mu > 0$ on average, but in some cases it could be painfully negative! At that point, you will ask yourself "am I better off to stop here or to continue?"

- well if you still trust that your steps are i.i.d like $N(\mu,\sigma^2)$, you should continue, because the math tells you that after further $k$ steps you will be on average $k\mu$ better off than now. Right?

- the same applies for the limit. Intuitively, why should you stop at step $n$ if you expect that after after 1 step you will be $\mu$ better off than now?

- of course, if you don't trust your trading strategy anymore, that's another story. It's not about stoploss/takprofit, I leave it off here for simplicity.

- so in theory, if you trust your trading strategy, the optimial values are stoploss=$-∞$ and takeprofit=$+∞$

- in practise, nobody prevents you from setting takeprofitt=$+∞$, but you can't have stoploss=$-∞$ because you have limited capital. If you don't set a stoploss barrier, your broker will set it for you equal to all of your capital (with some extra safety margin).

- so how do you set your stoploss in practice? Look at the money management theory for this. Spoiler: there is no no optimal value. It depends on your greed VS risk aversion.

- a quick example (study money management for more!). If you set stoploss=100% of your initial capital, you will be wiped out if the first trade goes bad, but if you are plain lucky you will enjoy a huge ROI. On the contrary, if you set stoploss=1% of your initial capital, you are much less likely to be ruined, but on average you get 100 times worse ROI than the "all-in" case.

## Answer by Hasselhoff (score 1)

https://quant.stackexchange.com/a/80007

It's really important to optimize this step. Returns are not a random walk. If they were, then you could set your stop loss to .25 of a step and take profit to .75 of a step with an expectancy ratio of `(.75/.25 * .5) - .5 = 1`. That would be sweet! Most returns are probably closer to cauchy, than normal or log(normal). Even if they are a random walk, obviously taking a smaller loss 50% of the time than the profit you get the other 50% seems like a pretty good idea to me. Also, if the moments of the return distribution even exist, they definitely won't be stationary, which could be scary. Pure theory will not get you out of the predicament.

I use a machine-learny process comparing a max norm of training data to fitting data with cosine similarity, and then use that set of fit parameters on unseen data. I do this for successive weeks so it mimics real time trading with no forward bias.

- Split the data into training, fitting and unseen. Training data is trailing M periods; fitting data is trailing N periods; unseen data is a single period. The sets are mutually exclusive, st training data occurs before fitting data which occurs before unseen data.

- Fit a grid of stop-loss and take-profit pairs over the training data and calculate a few performance metrics, like win%, mean return, volatility, total return, or whatever features you want to optimize your trades on. The paper mentioned above by Jacques is actually a nice way to help choose the grid to train on.

- Find the stop and take pair that results in the max norm of the vector of performance metrics on the training data.

- Calculate the same grid of stops and takes on the fitting data and ouput the performance metrics again. Find the grid pair that maximizes cosine similarity to the vector of performance metrics which had the max norm from step 3.

- Apply the single grid pair chosen from step 4 to the unseen data, which had max cosine similarity with the performance from the training data. This is a single period return. Do this for every single period in the entire data set. Since it is financial time series, make this process in ordered succession. Thus it simulates the decision process without forward bias since both the training and fitting data come before the unseen data. Remember too that the sets of data must be mutually exclusive.

There are many variations and set ups for this as well, like deciding what performance metrics to use and the size of M and N. You could also look at using dot product or other distance metrics instead of cosine similarity. It's a pretty flexible process.

If fitting all those grids of stops and takes sounds daunting, I got a tip from a friend which is nice. Get all the highs and lows of you trades, then get the high before low and low before high on each trade. Then you can get a pretty good approximate (yet not totally true) stop-loss and take-profit return series by using very quick set of if-else statements. For me it is 1000 times faster than actually getting the true return and good enough to optimize on.

## Answer by Theo Giannoukos (score 0)

https://quant.stackexchange.com/a/66447

marketinout.com has a stop loss optimisation tool that calculates the stop loss, trailing stop and take profit % in increments you set , based on the strategy you input. It outputs 1000 calculations sorted by the parameters with the most profit for the set time frame. https://www.marketinout.com/stock-screener/backtest/optimization/maintenance.php

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.