Skip to content

Guide

How do I set a stop loss or take-profit from a TradingView alert?

On a live account, build the stop loss or take-profit into your strategy and let its fill send the exit. Nyria places market and limit orders and attaches no stop or target to a live entry. When a strategy.exit level hits, TradingView fires an Order fills only alert, and Nyria reads it as an exit and closes the position. A stop or target that lives only on a chart never reaches your broker.

Official documentation

Exit at a stop or a target

  1. 1

    Write the exit into the script

    In a strategy() script, add strategy.exit with a stop, a limit or both. The price levels live in TradingView, not at your broker.

  2. 2

    Alert on order fills only

    Create the alert on the strategy and pick Order fills only. When strategy.exit fills, TradingView sends one alert for it.

  3. 3

    Turn exits on

    On the Nyria strategy, set Close on exit alerts on for the side you hold. With it off, exit alerts for that side are ignored.

  4. 4

    Or send CLOSE from an indicator

    An indicator with no strategy can alert when price crosses your level. Send CLOSE with the direction you hold, and Nyria closes all of it.

  5. 5

    Check it on paper first

    Deploy a paper bot, let the level hit and read the strategy's Logs tab. The exit should show as closed, not Skipped.

Exit payloads to copy

Exit from a strategy() fill

{
  "ticker": "{{ticker}}",
  "action": "{{strategy.order.action}}",
  "marketPosition": "{{strategy.market_position}}",
  "prevMarketPosition": "{{strategy.prev_market_position}}"
}

Exit from an indicator alert

{
  "ticker": "{{ticker}}",
  "action": "CLOSE",
  "direction": "LONG"
}

What Nyria does with a stop or target

  • Nyria attaches no stop order to a live entry.
  • A live position closes when an exit alert arrives.
  • CLOSE closes the whole position. There is no partial-close field.
  • An exit with nothing open is logged Skipped and sends nothing.

Where the level lives

  • The stop or target is a rule in your script, so TradingView decides when it hits.
  • The exit goes out when the alert arrives, not before.
  • A level drawn by hand on a chart sends nothing unless an alert watches it.

Questions

Can I send a stop loss with a TradingView entry alert?
On live accounts, no. Nyria places market and limit orders. Nyria Paper, Alpaca paper and Tradier sandbox take bracket orders on stocks and ETFs. Put the stop in your script and let its fill send the exit alert.
Can I send a stop order from a TradingView alert?
On live accounts, no. Alpaca paper and Tradier sandbox take stop orders on stocks and ETFs. A strategy.exit stop in Pine fires an order-fill alert when it hits, and Nyria treats that as an exit.
How do I take-profit at a target?
Add a limit level to strategy.exit, or alert when price crosses the target and send CLOSE. Either one arrives as an exit alert and closes the whole position.
Can I take-profit in parts?
Not on one position. CLOSE closes all of it, and there is no partial-close field.
What does it cost?
Paper is free. Live trading from $15 a month.

Next

Try a paper bot first

No card required. Paper is free. Live trading from $15 a month.