# Optimization of Take-Profit and Stop-Loss

Three questions:

1. 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.

2. 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?

3. 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.

• Maybe a better way to ask this: How do I optimize MAE and MFE? – Meuchedet Aug 22 '19 at 15:40
• MAE = Maximum Adverse Excursion, MFE = Maximum Favorable Excursion – Alex C Oct 26 '19 at 1:07

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.

• +1 Thank you so much. I am currently in the process of teaching myself linear algebra. i'd like to know a course of study so that I can continue to learn myself and advance to learning Operations Research. Can you tell me what subjects to learn? I can read the textbooks myself... – Meuchedet Aug 7 '19 at 13:26
• We made use of this book at university: "Introduction to Mathematical Programming: Volume 1: Applications and Algorithms" by Wayne L. Winston, M. A. Venkataramanan. It may not be the best book but it is a good book. – Jacques Joubert Aug 7 '19 at 17:59
• May I humbly add that I can't believe such a question doesn't have an obvious answer. I apologise in advance if this sounds conceited, but it comes up so much in finance. It is incredibly common. I am also commenting on order to boost viewers... – Meuchedet Aug 14 '19 at 19:20
• I don't follow the first statement. How can a trade have a drawdown and a profit at the same time ? thanks. – mark leeds Oct 25 '19 at 23:37
• It might start with a drawdown and then go to profit. – Meuchedet Oct 28 '19 at 7:00

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.