Skip to content

Guide

How do I send a limit order from a TradingView alert?

Add "order_type": "limit" and a price to an alert that names action (OPEN or CLOSE) and direction (LONG or SHORT). Nyria places the order at your price, whatever order type the strategy uses. It rests at the broker until it fills or is canceled. Market and limit are the only order types Nyria places, on every broker. On a TradingView position change with marketPosition and prevMarketPosition, order_type is ignored and the strategy's own setting applies.

Official documentation

Place a limit from an alert

  1. 1

    Name action and direction

    Nyria reads order_type on an alert with action OPEN or CLOSE and direction LONG or SHORT. A plain buy or sell on a listed stock, ETF or crypto ticker works too.

  2. 2

    Add order_type and price

    Set "order_type": "limit" and "price" to a decimal. In TradingView, {{close}} fills in the bar close.

  3. 3

    Or set it on the strategy

    Under Long and Short behavior, pick Limit order for entries or exits. Then pick a limit target: Bid, Ask, Mid, Custom or Alert price.

  4. 4

    Send a price with Alert price

    With the limit target on Alert price, an alert without a price is rejected. Any other target fills the price in for you.

  5. 5

    Set the duration on the strategy

    Duration is Day, Good till canceled or Fill or kill, per side. The alert has no field for it.

  6. 6

    Watch it on a broker's paper

    Nyria Paper fills or refuses a limit at once, so it never shows a resting order. Test the resting part on Alpaca paper or Tradier sandbox.

Payloads to copy

curl, a resting limit entry

curl -X POST https://trades.nyria.io/webhooks/YOUR_TOKEN \
  -H "Content-Type: application/json" \
  -d '{
    "action": "OPEN",
    "ticker": "BTCUSD",
    "direction": "LONG",
    "order_type": "limit",
    "price": 64000
  }'

TradingView message, limit at the bar close

{
  "ticker": "{{ticker}}",
  "action": "OPEN",
  "direction": "LONG",
  "order_type": "limit",
  "price": {{close}}
}

Where order_type is read

  • An alert with action OPEN or CLOSE and direction LONG or SHORT.
  • A buy or sell for a listed stock, ETF or crypto ticker, with nothing beside price, order_type and a timestamp.
  • A position change, a Discord or Telegram message and a Provided in alert options strategy keep the strategy's order type.

What a limit cannot do

  • Nyria places market and limit orders. Exits come from exit alerts.
  • MODIFY re-prices a resting limit at Alpaca or Tradier. At Charles Schwab and tastytrade, send CANCEL, then a new OPEN.
  • CANCEL pulls a resting entry before it fills. A filled order is a position, so close it with CLOSE.
  • Force market orders on the bot sends every order at market, whatever the strategy says.

Questions

Why did my alert place a market order when I set limit?
Most often the alert was a position change with marketPosition and prevMarketPosition, where order_type is ignored. A Discord or Telegram message, a Provided in alert options strategy or Force market orders on the bot do the same. Set the order type on the strategy, or send action and direction.
Why was my limit alert rejected?
The strategy's limit target is Alert price and the alert carried no price. Send a price on every alert, or change the target to Bid, Ask or Mid.
Can I send a stop order from a TradingView alert?
On live accounts, no. Nyria places market and limit orders. 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 long does a resting limit stay open?
As long as the strategy's Duration says: Day, Good till canceled or Fill or kill. tastytrade and Tradier don't accept FOK, so Nyria sends Day. At Alpaca, options go as Day and crypto as GTC.
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.