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
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
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
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
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
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
- Paste an alert into the alert tester to see how Nyria reads it.
- Write a TradingView message with the alert builder.
- Step by step for one account: how to automate TradingView to Alpaca.
- Step by step for one account: how to automate TradingView to Tradier.
- TradingView alert message builder.
Guides
TradingView alert placeholders
Every {{ticker}} and {{strategy.*}} placeholder, what it becomes when the alert fires.
Read guideHow do I auto execute trades from a TradingView strategy?
An alert on the strategy, Order fills only, and the strategy placeholders in the message.
Read guideHow do I send a limit order from a TradingView alert?
order_type limit plus a price, on an alert that names action and direction.
Read guideHow do I close or reverse a position with a TradingView alert?
CLOSE with the direction exits. One alert that reports the flip reverses.
Read guideHow do I automate trades from a TradingView indicator?
One alert per side, Once per bar close, action and direction in each message.
Read guideTry a paper bot first
No card required. Paper is free. Live trading from $15 a month.