Pine Node Editor
Home Tutorial Guides Pricing
Add to Chrome
Guide

Take-profit, stop-loss, trailing stop and exits

Risk Config, explained with examples.

Connect a Risk Config node to the config input of your Long and Short Signal nodes. Its values become inputs in the strategy's TradingView Settings, so you can tune them on the chart.

Units: % of price or ATR

  • % of price (default): take-profit 2 means +2% from the entry price.
  • ATR multiple: connect an ATR node to Risk Config's atr input and switch "Stop units". Take-profit 3 then means 3 × the current ATR. Stops adapt to volatility instead of using the same % in quiet and wild markets.

How take-profit and trailing stop combine

Take-profitTrailing stopWhat happens
set0A normal take-profit order.
0setThe trailing stop switches on once price has moved the trailing distance into profit, then follows the best price at that distance.
setsetNo fixed take-profit: when price reaches the take-profit level, the trailing stop switches on and follows the best price at the trailing distance. Lets a winner run instead of capping it.
00The position closes only by stop-loss or an exit signal.

Example in ATR mode: take-profit 3, trailing 0.5 → once the trade is 3 ATR in profit, a stop follows 0.5 ATR behind the best price. Because both values are TradingView inputs, setting trailing to 0 on the chart turns take-profit back into a normal limit order without regenerating.

Stop-loss and break-even

  • Stop-loss is a resting stop order at the set distance from the entry price. 0 disables it — the strategy then has no limit on a losing trade.
  • Break-even trigger: once a bar closes that far in profit, the stop moves to the entry price and stays there even if price pulls back.

Leverage

Leverage in Strategy Settings scales the position size (same capital, bigger position). The editor also estimates the liquidation price (isolated margin, ignoring fees and funding) and never lets the stop sit beyond it, so a wide stop at high leverage reports the liquidation that would really happen first.

Exits from your own logic

  • Exit Signal closes the position when its trigger is true. Choose Any position, Long only or Short only: "close longs when RSI > 70" won't touch a short.
  • Time-based exit (Pro): Position State → bars_in_trade → Compare >= 20 → Exit Signal closes any trade still open after 20 bars.
  • Profit-based logic (Pro): Position State's open_profit_pct is the open trade's profit in % at the bar's close.

Reversal

By default an opposite signal is ignored while a position is open, so one noisy signal can't flip you from long to short. Turn on Allow signal reversal in Risk Config if you want the opposite signal to close the position and open the other side.

Things a backtest can't see

TradingView's backtester doesn't know the exact price path inside a bar. When take-profit and stop-loss could both be hit in the same bar, it has to assume an order, and a very tight trailing stop usually looks better in a backtest than it does live. See Can I trust this backtest?

More guides: all guides · step-by-step tutorial · what's new

© Pine Node Editor. All rights reserved.
Guides Changelog Privacy Policy Terms of Service Contact