How to Set a Breakeven Stop and Stop Profit (with code in Easylanguage)

by Andrea Unger

Need More Help? Book Your FREE Strategy Session With Our Team Today!

We'll help you map out a plan to fix the problems in your trading and get you to the next level. Answer a few questions on our application and then choose a time that works for you.


The break-even stop is a mechanism for closing positions that can help you limit risk. For this reason, it's widely used in both discretionary and systematic trading.

In this video, you'll find a lot of essential information to help you learn how to use this kind of stop correctly.

In addition to explaining what the break-even stop is and how it works, in the video, we also explain:

 - how to code it in MultiCharts and TradeStation (you’ll find the scripts of two different versions, one using a monetary amount and one using points);

 - how to use and code the stop profit, which is a variant of the break-even stop that lets you try  covering a part of the operating costs;

 - how to choose the most appropriate values during the development and optimization  of your strategies to avoid overfitting or calculation errors during backtesting.




Hi again everyone and welcome to this brand new video.

I'm one of the coaches of Unger Academy, and today, we're going to be talking about the break-even stop, a tool that's widely used both in discretionary trading and in systematic trading to manage positions, and more in particular, to protect ourselves from risk.

Okay, let's start with our video. First things first, we're going to see what the break-even stop is and what its purpose is. Then, we're going to see how to set it up in MultiCharts and TradeStation, and we'll also talk about the "stop profit", which is a variation of the break-even stop. I'll show you how to code this variation in MultiCharts and TradeStation. Finally, I will tell you what elements we take into account when we evaluate break-even stop values.

But it's a good thing to start from the beginning. So, what is the break-even stop?

What is the Breakeven Stop

The break-even stop is a stop order, which means that it's executed at a worse price than the market price and is placed on the entry price as soon as a certain amount of profit is reached. This stop can be expressed either in points or as a monetary amount (depending on your trading platform) and represents the point of gain of the open position.

The purpose of this stop is to reduce the risk of an open position by closing it when it reaches a specific target of profit.

Please keep in mind that this doesn't apply when gaps occur. Consider, for example, setting a break-even stop of a certain amount and maintaining your position open over the weekend (and the market you're trading is closed on the weekend, of course). When the market opens again on Monday, there can be a significant gap. In that case, the break-even stop may be skipped. The stop order is filled when the market touches the first advantageous price once this level is reached, but since this level is no longer available, the order will be obviously filled at a worse price than the one you initially set.

Breakeven in systematic trading vs discretionary trading

As I've already mentioned, the break-even stop is employed both in discretionary trading and in systematic trading. Generally, discretionary traders tend to use break-even stops that are pretty tight. Whether this is a good practice or not obviously depends on the strategy that you're using. With regard to systematic trading, setting very tight values, especially in the case of stop limit orders, is usually very risky because trading platforms are unable to test them effectively. But we will see it later on in this video. 

So, when you use break-even stops, my advice is always to go and check a couple of things during the process you generally go through when you set your orders so that you can better evaluate the effectiveness of the order that you're setting up and make sure that the backtest results you're getting are not the product of some mistake or incorrect calculation process of the platform, but that they can actually be used with some confidence both in backtesting and in real trading.

Breakeven chart example on the Gold Future

Here you can see an example of how to apply the break-even stop. This is the Gold Future, and as you can see, after the entry, there's a break-even stop of $750. Once the position has achieved this amount, the break-even order is placed on the entry price. In this case, unfortunately, the market made a retracement and hit the break-even stop. Since the position was closed, it's impossible to hope that the trade will recover; however, that stop would have protected us if the market had fallen significantly, enabling us to close the position before hitting a stop loss.

Coding in MultiCharts / TradeStation

Let's go and see how to code break-even stops in MultiCharts and TradeStation. There are two keywords you can use. Basically, they do the same thing but let you express the concept in different ways.

The first keyword is "setbreakeven". In this case, the amount of the break-even stops that you specify between the round brackets must be expressed as a monetary amount. On the other hand, if you use the other keyword, which is "setbreakeven_pt," the amount between brackets will be expressed in ticks or points.

So the meaning is exactly the same because each monetary amount obviously corresponds to a certain number of points or ticks. This means that there are no differences in terms of effectiveness but only in terms of form since these are two different ways of expressing the same concept and the same action.

When you use these keywords, especially in case you're trading on futures, you must include the command "setstopcontract", which allows you to specify that the amount written between the brackets in the two functions I've just mentioned refers to each contract and not to the total position.

Let's make an example. Suppose setting a $1,000 break-even stop on a certain product and opening a position with two contracts. If you didn't use the "setstopcontract" command, the platform would actually place a $500 break-even stop per contract, which equals a total of $1,000.

However, since the break-even stop represents the distance - expressed in dollars, points, or ticks - from the entry price, we need to include the "setstopcontract" command to make sure that if we trade two contracts the total break-even will be $1,000 per each contract, which means a total of $2,000.

Here you can see an excerpt from the MultiCharts user's guide in which the same things are explained. So here's the "setbreakeven" command and, between the brackets, the amount to be used.

Code alternative: stop-profit version in TradeStation / MultiCharts

We often hear traders - well, mainly systematic traders - talk about a sort of break-even stop that's not really a "break-even" but rather an order that is placed slightly above the entry price if you're trading long or slightly below the entry price if you're trading short. So rather than "break-even stop," in this case, we may talk about "stop profit." Anyway, the purpose of this kind of stop is to reduce somehow the impact of trading costs such as commissions, spread, and slippage.

Unfortunately, MultiCharts and TradeStation don't provide any position management function for this kind of stop. However, coding this stop is not that complicated. Here you can see how to code two versions of the "stop profit": one that works with a monetary amount and one that works with an amount expressed in ticks.  

But let's see how they work more in detail. The first version, so the one working with Cash, allows us to specify first the monetary amount that activates the break-even stop, between brackets, and then the offset, so the difference between the break-even stop and the entry price.

This offset is calculated on line 4 and corresponds to the amount that will be either added to the entry price in the case of long positions or subtracted from the entry price in the case of short positions. Then on lines 7 and 8, we have the instructions to send the long and short orders, respectively.

The same things are done in the second version because the process is exactly the same. The only difference is that instead of using monetary amounts, we use ticks to specify the different values since perhaps some people may find ticks more comfortable than monetary amounts.

Let's make an example.

Stop-profit chart example on Gold Future

I added the script of the stop profit to my trading system - the one I used as an example at the beginning of this video - after disabling the break-even stop, of course. So I set the activation threshold for the break-even stop at $2,000, and then I set the break-even stop value itself at $250 above the entry price. If we used the second version of the stop profit, we would have had to express the offset in ticks, so since we are applying this system to the Gold Future, the offset would have been 25 ticks above the entry price. And as you can see, in this case, the position isn't closed exactly on the entry price, as it happened in the previous case, but it's closed slightly above that price.

Evaluation of the breakeven

Now let's move on to a topic that I consider extremely important: how to evaluate break-even stop values properly. As I've already told you in our video on the stop loss, it's essential to evaluate the effectiveness, and above all the robustness of the values that we choose for our stops. This applies to the stop loss, as well as to the break-even stop and even to the profit target. In the case of the profit target, there are fewer risks if you pick an excessively wide value, but choosing a value that is too tight could be very risky.

So back to the break-even stop value, as a general rule, it shouldn't be either too tight or too wide, exactly as the stop loss, and obviously, it must be chosen according to the time horizon of the strategy in which you're using it.

In fact, a system that keeps the positions open for a long time could be traded with a slightly wider stop than a system that keeps positions open for a short time. 

Another essential thing is to pick a value that is in a stable area. 

There is also another rule, but I didn't write it here because it's pretty obvious, and it's that you need to choose a value that's lower than the profit target. In fact, if you placed the break-even stop at a higher level than the profit target, the position would hit the target before reaching the stop. This means that you would hit the target even before placing the break-even stop. But you know, this is pretty obvious, which is why I didn't write it.

But back to the stability issue, it's extremely important that you carefully evaluate the results you get during the optimization of the break-even stop inputs. For example, in this case, you need to look at the last column you see here and pick a value that's surrounded by other values that also produce good results. 

You definitely need to avoid isolated values or values that could be unstable because in that case, you'd risk falling into overfitting or using a value that's working only by pure chance.

Generally speaking, the riskiest values are the lower ones. Look, for example, at the first values, such as 1 or 2. They make a very large number of trades, especially value 1. The reason why they do this is that positions are closed almost immediately after being opened, so the platform can't always identify the correct exit points, and so it may produce inaccurate and unreliable backtest results. So that's why it's so crucial to avoid these values, and the same goes for the stop loss, of course.

During the evaluation of these values, we usually look for values that produce stable results in terms of net profit, average trade, and drawdown.

If it's more convenient for you to represent these results differently, you can export the MultiCharts report, no problem. Let's go back here for a moment. Can you see the disk icon here? Now, this icon lets you save the report so that you can process the data as you prefer, for example, importing them into Excel and creating a histogram. This way, evaluating the different parameters will be easier.

For example, in this case, I have identified a stability area around these values delimited by the green lines. As you can see, the value 15, which in this case stands for 15 points, turns out to be a good and stable value according to two different parameters. So I would most likely pick 15 as a value for this very reason.

And with that, our video about the break-even stop is over. We've explained what the break-even stop is and how traders generally use it, making a comparison between how it's used in systematic trading and discretionary trading. I've also told you about the criteria that I use when I pick the values for the break-even stop when I use it in my automated strategies. 

Now it's up to you to delve deeper into this topic, which is definitely very important for traders, and in fact, we also deal with it in our training programs.

If you enjoyed this video, and if it has helped you, I invite you to hit the "like" button and go and share it with everyone. And if you have any questions or ideas, please write them in the comments! 

And once again we remind you to take a look at the link you see in the description of this video, where you'll find a completely free webinar about how to build trading systems following the method of the only 4-time world trading champion with real money Andrea Unger.

Will see you in our next video dedicated to the world of trading systems. 

Until then, keep safe. Bye-bye!


Need More Help? Book Your FREE Strategy Session With Our Team Today!

We’ll help you map out a plan to fix the problems in your trading and get you to the next level. Answer a few questions on our application and then choose a time that works for you.


Andrea Unger

Andrea Unger here and I help retail traders to improve their trading, scientifically. I went from being a cog in the machine in a multinational company to the only 4-Time World Trading Champion in a little more than 10 years.

I've been a professional trader since 2001 and in 2008 I became World Champion using just 4 automated trading systems. 

In 2015 I founded Unger Academy, where I teach my method of developing effecting trading strategies: a scientific, replicable and universal method, based on numbers and statistics, not hunches, which led me and my students to become Champions again and again.

Now I'm here to help you learn how to develop your own strategies, autonomously. This channel will help you improve your trading, know the markets better, and apply the scientific method to financial markets.

Becoming a trader is harder than you think, but if you have passion, will, and sufficient capital, you'll learn how to code and develop effective strategies, manage risk, and diversify a portfolio of trading systems to greatly improve your chances of becoming successful.