Backtesting Concepts

Stop-Loss, Take-Profit & Trailing Stops

How protective exits work -- stop-loss, take-profit, trailing, break-even, and time-based exits -- how they interact with spreads and leverage, and the tradeoffs of tight vs wide levels.

Stop-Loss, Take-Profit & Trailing Stops

Your exit conditions define when to close a trade based on indicator signals. But sometimes a trade moves sharply against you before any signal fires, or it reaches a level of profit you want to lock in. Stop-loss, take-profit, trailing stop, break-even stop, and time-based exit orders handle these situations automatically -- they close the position when price hits a predefined level (or, for a time exit, after a set number of candles), regardless of your signal-based conditions.

Stop-Loss

A stop-loss closes the position when the price moves against you by a specified percentage. It caps your loss on any single trade.

In Simula, you set the stop-loss as a percentage of the entry price. If you enter a long trade at 100 with a 5% stop-loss, the stop triggers at 95. If the candle's low reaches 95 or below, the position is closed at the stop-loss level.

For short trades, the direction is reversed. A 5% stop-loss on a short entry at 100 triggers at 105 -- the danger direction for a short is the price rising, so the stop is placed above the entry.

Take-Profit

A take-profit closes the position when the price moves in your favor by a specified percentage. It locks in a gain before the market has a chance to reverse.

If you enter a long trade at 100 with a 10% take-profit, the position closes at 110. For a short trade at 100, a 10% take-profit triggers at 90 -- the profit direction for a short is the price falling.

TP+10%EntrySL-5%TP hitReward zoneRisk zoneStop-loss caps the downside -- take-profit locks in the upside
SL and TP are independent of your exit conditions
Stop-loss and take-profit work alongside your signal-based exit conditions, not instead of them. If your exit signal fires before the SL or TP is reached, the position closes on the signal. If the SL or TP is reached before the signal fires, the position closes on the level. Whichever happens first wins.

Trailing Stop

A trailing stop is a stop-loss that moves in your favor as the trade progresses. Instead of staying fixed at a level below your entry, it follows the price upward (for long trades) and locks in progressively more profit.

In Simula, you set the trailing stop as a percentage. For a long trade with a 5% trailing stop, the engine tracks the highest price reached since entry. The trailing stop level is always 5% below that high. If the price rises from 100 to 120, the trailing stop moves from 95 to 114. If the price then drops to 114 or below, the position is closed.

The key property: the trailing stop only moves in your favor. It ratchets up with new highs but never moves back down. This means it progressively tightens the exit as the trade becomes more profitable.

EntryExitPriceTrailing stop (5%)The trailing stop ratchets up with price but never moves back down

For short trades, the trailing stop tracks the lowest price reached since entry and sits a percentage above it. It ratchets downward with new lows and exits when the price rises back to the trailing level.

Break-Even Stop

A break-even stop protects a trade that has already moved in your favor. You set an activation threshold as a percentage gain. Once the trade reaches that gain, a stop is placed at your entry price -- so if the market reverses, the position closes at breakeven rather than turning a winner into a loser.

In Simula, you set the break-even stop as the activation gain. For a long trade entered at 100 with a 5% break-even stop, nothing happens until the price rises to 105. At that point the stop arms at 100 -- your entry. If the price then falls back to 100, the position closes at breakeven (before trading costs). If the price keeps rising, the stop stays at 100 -- unlike a trailing stop, it does not keep moving.

+5%ActivationEntryBreak-even stopStop activates at entryExit at breakevenOnce the trade gains 5%, a stop activates at entry -- a reversal then closes at breakeven

The activation is a one-way latch: once the trade has hit the threshold, the stop is armed for the rest of the trade even if the price later retraces below the activation level. It never disarms.

For short trades, the direction is reversed. A 5% break-even stop on a short entered at 100 arms once the price falls to 95; the stop then sits at 100, closing the position at breakeven if the price rises back to entry.

Break-even stop vs trailing stop -- what is the difference?
Both move the exit in your favor, but they are different tools. A trailing stop continuously ratchets a stop a fixed percentage behind the best price, locking in progressively more profit as the trade runs. A break-even stop sets a single stop -- at your entry -- once a gain threshold is reached, and then holds there. Use a break-even stop to take downside risk off the table after a trade starts working; use a trailing stop to keep capturing an extended move.
A break-even stop works on its own
A break-even stop does not require a fixed stop-loss. You can run it alone, or alongside a stop-loss and/or a trailing stop. When more than one stop is active, whichever sits closest to the current price -- the tightest -- is the one that closes the position. Before the break-even stop arms, your other stops behave normally; once it arms, the level at entry is usually the tightest stop and takes over.
When should I use a trailing stop vs a fixed stop-loss?
A fixed stop-loss caps your maximum loss but does not adapt as the trade moves in your favor. A trailing stop lets winning trades run while progressively tightening the exit. The tradeoff: trailing stops can get triggered by normal price fluctuations during a trend, closing a trade that would have continued to profit. If your strategy relies on capturing large moves, a wider trailing stop or no trailing stop may produce better results. If you want to protect gains incrementally, a trailing stop is the tool for that.

Time-Based Exit

A time-based exit closes the position after it has been open for a set number of candles, no matter where the price is. It is a maximum holding period -- a cap on how long any single trade can stay on.

In Simula you set the time exit as a whole number of candles. For a long trade with a 4-candle time exit, the position is force-closed at the close of the fourth candle after entry. The count is the same for long and short trades.

EntryForce exitExit at candle close01234candles since entryNo stop was hit -- the trade is closed only because it reached its 4-candle holding limit

Unlike the other protective exits, a time exit is not a price level. It does not care whether the trade is up, down, or unchanged -- when the candle count is reached, the position closes at that candle's close. Because it is a holding-period cap rather than a price move, it fires on the same candle no matter what leverage you trade; leverage only changes how much that exit's result is multiplied in your portfolio.

A time exit is most useful for cutting loose trades that go nowhere. If your edge is meant to play out within a few candles, a position still open well past that point is often just tying up capital and exposure with no thesis behind it. A time exit bounds that risk directly, in candles, instead of waiting for a price-based stop that may never be reached. The best holding period is rarely obvious up front -- testing a range of values with parameter optimization is usually more reliable than guessing.

Does a time exit fire before or after my stop-loss?
Price-based stops are checked first. A stop-loss, take-profit, trailing stop, or break-even stop can trigger anywhere within a candle, so if one of those is reached on the same candle the time limit comes due, the price stop closes the trade and gets credited. The time exit only closes the position if no price stop has already done so. It does, however, take precedence over your signal-based exit conditions on the candle it fires.
A time exit works on its own or alongside other stops
You can run a time exit by itself or together with any combination of stop-loss, take-profit, trailing stop, and break-even stop. Each works independently: the price stops watch the price, the time exit watches the candle count, and whichever condition is met first closes the trade.

Gap Execution

In live markets, the price can jump over a stop-loss or take-profit level without ever trading at it. This is called a gap -- it happens between trading sessions or during sudden price moves.

Simula models this realistically. If a candle opens past your stop-loss or take-profit level (the open price has already blown through the level), the exit executes at the candle's open price, not at the SL/TP level. This means the actual loss can be larger than the stop-loss percentage, or the actual gain can be different from the take-profit percentage.

For example: you enter a long trade at 100 with a 5% stop-loss (level at 95). Overnight, the market drops and the next candle opens at 92. The engine exits at 92, not 95 -- resulting in an 8% loss rather than the 5% you set. This is realistic -- in live trading, a stop-loss order guarantees an exit, not a price.

Stop-loss is not a guarantee of a specific loss
A 5% stop-loss means the exit triggers when price moves 5% against you. But if the price gaps past that level, the actual loss will be larger. This matters most on daily timeframes where overnight gaps are common, and on higher leverage where the amplified gap can be significant.

Exit Priority Order

When multiple exit mechanisms are active, they are checked in a specific order on each candle. If more than one would trigger on the same candle, the highest-priority mechanism is the one that closes the position and gets credited in the statistics.

1. Trailing stops and break-even stops are updated first. Both move with price -- the trailing level ratchets with new highs, and the break-even stop arms once its activation gain is reached -- so their levels are recomputed before any exit is checked. Being updated first does not mean they always win: once a break-even stop is armed it sits at your entry and competes with your other price-level stops, and whichever level the candle reaches first is the one that closes the trade.

2. Stop-loss and take-profit are checked next. These are evaluated in the order they appear in your setup. If both levels are breached on the same candle, stop-loss is evaluated first by default.

3. Time-based exit is checked next. The price stops above can fire anywhere within a candle, so they are resolved first; the time exit is a close-of-candle event that only closes the position if no price stop already did. When the holding limit comes due, it fires at that candle's close.

4. Custom exit conditions are checked last. If no price stop and no time exit triggered, the engine evaluates your signal-based exit conditions.

What if both a stop-loss and an exit condition trigger on the same candle?
The stop-loss takes priority. The exit is attributed to the stop-loss in the performance statistics, and the custom exit condition is ignored for that trade. This hierarchy ensures risk management mechanisms always take precedence over signal-based exits.

Spreads on Protective Exits

Spread is applied on every exit, including stop-loss, take-profit, trailing stop, break-even stop, and time-based exit. For a long trade, you sell at the bid. For a short trade, you buy back at the ask. The spread cost is the same regardless of how the position is closed.

This means the effective stop-loss level is slightly worse than the percentage you set, and the effective take-profit is slightly less generous. With tight SL/TP levels and a wide spread, the spread cost can be a meaningful portion of the trade's outcome.

Leverage and Protective Exits

Stop-loss, take-profit, and trailing stop percentages are always based on the asset's price movement from your entry price -- not on your portfolio return. This distinction matters when you trade with leverage, because leverage multiplies the portfolio impact of every price move.

Suppose you enter a long trade at 100 with a 5% stop-loss. The stop triggers when the price reaches 95 -- a 5% price drop. That trigger point is the same at 1x, 3x, or 10x leverage. What changes is how much of your portfolio you lose when the stop fires:

At 1x leverage, a 5% price drop is a 5% portfolio loss. At 3x leverage, the same 5% price drop is a 15% portfolio loss. At 10x leverage, it is a 50% portfolio loss. The stop-loss did its job -- it exited at the price level you specified -- but leverage amplified the result.

The same applies to take-profit. A 10% take-profit at 3x leverage triggers when the price rises 10%, but your portfolio gains 30%. And a trailing stop set to 5% still ratchets based on the price peak, not on your leveraged return.

Higher leverage needs tighter stops
With leverage, the same stop-loss percentage produces a larger portfolio hit. A 5% stop-loss that feels comfortable at 1x becomes a 25% drawdown at 5x. If you increase leverage, consider tightening your stop-loss to keep your per-trade risk within a level you are comfortable with.

Tradeoffs: Tight vs Wide Levels

Tight Stop-Loss

A tight stop-loss (1-2%) limits the loss per trade but gets triggered frequently by normal price noise. The result is many small losses. If the strategy relies on capturing larger moves, tight stops can chop it apart -- the trade gets stopped out during a temporary dip and then the price resumes in the profitable direction without you.

Wide Stop-Loss

A wide stop-loss (10-20%) gives the trade room to breathe through normal fluctuations, but each losing trade hurts more. The risk-reward ratio needs to compensate -- if you are risking 15% per trade, the winners need to be large enough to offset those losses.

No Stop-Loss

Running without a stop-loss means the position only closes on your signal-based exit conditions or at the end of the backtest period. This avoids being stopped out prematurely, but it leaves the position fully exposed to large adverse moves. The max drawdown of a strategy without stop-losses can be significantly deeper than one with them.

Take-Profit Levels

A tight take-profit locks in small, frequent gains but caps the upside on trades that would have continued to run. A wide take-profit allows for larger wins but means the price has to move further before the gain is secured -- and it might reverse before reaching the level. Many strategies perform better without a take-profit at all, letting the exit conditions determine when to close based on market signals rather than an arbitrary percentage.

Testing different levels?
If you find yourself manually trying different stop-loss or take-profit percentages, parameter optimization can systematically test combinations for you and show which levels produce the best risk-adjusted results.

Where to Go Next

Entry & Exit Conditions -- the signal-based exits that work alongside SL/TP.

Long vs Short Strategies -- how SL/TP directions reverse for short positions.

Spreads, Commissions & Slippage -- the costs applied on every exit including protective exits.

Leverage & Position Sizing -- how leverage multiplies the portfolio impact of your protective exit levels.

Risk-Reward Ratio -- measuring whether your SL/TP levels produce a favorable risk profile.

Max Drawdown -- the metric most affected by stop-loss settings.