What strategy.exit is really doing here
For a query like tradingview pine script v5 strategy.exit stop limit syntax, the biggest confusion is usually around meaning, not raw syntax. In Pine Script, strategy.exit() is how you define exit orders for an open position. The interesting part is whether you are defining a stop-loss, a take-profit, a trailing behavior, or a bracket that combines both stop and limit levels.
That distinction matters because a lot of traders use the words “stop limit” loosely when they really mean “I want both a stop-loss and a target on the same position.” Those are not the same thing conceptually, and they should not be documented as if they were.
- use stop when you mean the loss-protection price
- use limit when you mean the take-profit price
- do not assume stop + limit means one combined entry order
- always check how the strategy tester is interpreting the exits
The clean pattern most traders should start with
A basic bracket exit is usually the best starting point: one entry, one stop price, one target price. That keeps the logic inspectable before you add partial exits, trailing behavior, or stateful management.
If the simple bracket is unclear, the complicated version will not become clearer later.
//@version=6
strategy("Exit syntax reality check", overlay = true)
if ta.crossover(ta.ema(close, 20), ta.ema(close, 50))
strategy.entry("L", strategy.long)
if strategy.position_size > 0
stopPrice = strategy.position_avg_price * 0.99
limitPrice = strategy.position_avg_price * 1.02
// In strategy.exit(), stop + limit creates a stop-loss and take-profit bracket.
// It is not a single stop-limit entry order.
strategy.exit("Bracket", "L", stop = stopPrice, limit = limitPrice)
Common mistakes that make the syntax look broken
Many complaints about strategy.exit are really design complaints. The code may compile, but the trader expected behavior the function was never meant to provide. The most common example is expecting a single stop-limit style object when the code is actually defining two separate exit thresholds for a bracket.
- placing exit logic without checking whether the position is open
- mixing percentage thinking with raw price levels carelessly
- treating a target and a stop as if they were one concept
- building the complex version before the simple bracket has been tested
How I check whether the exit logic is trustworthy
I want the exit logic to answer three questions cleanly. When does the trade become invalid? When is profit good enough to take? And does the tester behave the same way the author thinks the code behaves? If those answers are muddy, the exit block is not ready yet.
If the exit syntax is compiling but the behavior still feels wrong, send the relevant block on WhatsApp. I usually check whether the levels, order timing, and expectations are aligned before changing anything else.
WhatsApp for a 3-minute quoteWhat to read next
If this topic is part of a bigger TradingView or Pine Script workflow for you, these are the most useful follow-up guides on the site.
Send the chart idea, broker, market, and goal on WhatsApp. I can usually tell you quickly whether it needs a custom indicator, a strategy audit, an alert fix, or a broker-ready automation layer.
Related services
Frequently asked questions
Can strategy.exit use stop and limit together?
Yes. That is the normal way to create a bracket exit with a stop-loss and take-profit level for an open position.
Is stop plus limit in strategy.exit the same as a stop-limit entry order?
No. In strategy.exit, those parameters define exit thresholds for an existing position. They are not the same thing as a single stop-limit entry concept.
Why does my strategy.exit block compile but behave strangely?
Usually because the trader expectation and the actual order behavior are not aligned. The issue is often the logic around the function, not the function name itself.
Should I use raw price levels or percentage offsets?
Either can work, but the safer choice is whichever makes the exit logic easiest to inspect and explain for that specific strategy.
Primary sources and references
I take on Pine Script indicators, TradingView automation layers, strategy audits, and broker-aware execution workflows when the goal is clear and the live behavior actually matters.