Automatic Stop Loss and Take Profit Indicator for TradingView
A TradingView stop-loss and take-profit indicator calculates or draws levels. It does not place protective orders merely because lines appear on the chart. An alert, a simulated strategy exit, and an accepted broker order are separate steps, each with its own setup.
What does "automatic" mean in this setup?
| Component | What it does | What still needs checking |
|---|---|---|
| Indicator | Computes and plots stop or target levels | Entry reference, formula, update rules, and supported alert conditions |
| Alert | Sends a notification or configured webhook message when a condition triggers | Active alert, frequency, payload, and receiving service |
| Pine strategy | Simulates entries and exits in TradingView's broker emulator | Fill assumptions, costs, and whether the exit matches the intended rule |
| Broker bracket | Places supported stop and target orders against a position | Broker support, accepted order status, quantity, and cancellation behavior |
TradingView states that Pine strategies cannot directly place orders with its connected brokers. A strategy's order-fill alert refers to an emulator event. An external execution service needs its own connection and handling. See TradingView's strategy FAQ and strategy alert documentation.
Calculate an ATR stop and target
ATR measures the scale of recent price movement; it does not predict which direction price will move. See TradingView's ATR definition. An ATR-based distance changes with the volatility estimate. A percentage distance instead scales with price. Neither method has a universal performance advantage.
For an entry price E, an ATR value A, stop multiplier k, and target multiplier m:
| Position | Stop level | Target level |
|---|---|---|
| Long | E − k × A | E + m × A |
| Short | E + k × A | E − m × A |
For a hypothetical long entry at 100 with ATR of 2, a stop multiplier of 1.5 gives a stop at 97. A target multiplier of 3 gives a target at 106. The planned distance ratio is 6 to 3, or 2:1. These are arithmetic examples, not measured trading results; execution costs and gaps can change the realized amounts.
Check the units. An ATR calculated from a stock chart is expressed in that stock's price units. It is not automatically an appropriate stop distance for an option premium. Futures and other contracts also require their point value, tick size, and quantity rules when converting a price distance into money.
Decide whether levels stay fixed or trail
An entry-fixed rule saves the entry price and ATR when the trade starts, then keeps those initial distances. A rule that recalculates from the latest close and ATR can move a stop in either direction. If volatility expands, that may widen the planned loss distance.
A ratcheting trailing stop needs an explicit constraint: a long stop can stay level or move upward; a short stop can stay level or move downward. Define its reference, such as the highest price since entry, and when it updates. A line labeled "trailing" is insufficient evidence that the implementation follows that constraint.
Do not assume a trail protects a fixed amount of profit. A stop order can execute away from its trigger price, while a stop-limit order may not execute at all. Schwab explains that tradeoff in its stop and stop-limit order guide.
Set up and verify the indicator
- Add the chosen indicator and read its description or source. Identify how it detects an entry: a manual input, an external signal, or an internal rule.
- Set the price source, timeframe, ATR length or percentage, and multipliers. Check whether levels reset on a new signal or change while a trade is open.
- Compare one long and one short example with a hand calculation. Check a gap and a volatility expansion as well as an ordinary bar.
- If the script exposes a suitable alert condition, create an alert and select its trigger frequency. For a rule defined on confirmed closes, match the alert timing to that rule.
- Change a setting in a test setup and verify the alert configuration again. Existing alerts do not automatically adopt later indicator-parameter changes; recreate the alert when needed.
TradingView describes indicator alerts and their saved settings in Getting started with technical alerts. A notification is useful evidence that a condition fired, but it is not confirmation that a broker received or filled an order.
If you need actual protective orders
For a supported connected broker, use its stop-loss and take-profit order controls and inspect the resulting orders in the trading panel. TradingView's bracket documentation describes linked exits and notes that availability depends on the broker. Verify the exact behavior for partial fills, position changes, and cancellation in your setup.
For an external webhook workflow, confirm the endpoint receives the expected message, rejects duplicates appropriately, maps the correct symbol and quantity, and records the broker's response. A webhook sends a request to an external application; it is not itself a broker order. See TradingView's alert delivery options.
Test the complete sequence in an appropriate simulated environment: entry, protective-order acceptance, target or stop trigger, cancellation of the other exit, and final position size. Include a rejected order and a connection failure in that review. Only an accepted protective order demonstrates that protection was placed.
Evaluate the exit rule separately from the entry
To compare a fixed stop with an ATR stop, hold the entry signals, position-sizing method, dates, and cost model constant. Log each exit and compare loss size, drawdown, time in market, and net results. If using a risk budget divided by stop distance to calculate quantity, include contract value and allowed lot increments; this estimates planned exposure, not a guaranteed maximum loss.
These settings have no verified improvement percentage or win rate supplied here. The useful output is a rule you can calculate, test, and check against the orders that actually exist.

