Skip to content

Guide

Connect TradingView webhooks to Alpaca

TradingView cannot post a webhook directly to Alpaca. An alert sends a message to a URL; Alpaca is a broker, not an endpoint that reads alert text and places orders. The route is: TradingView posts to Nyria's webhook URL, and Nyria places the order at Alpaca. Here are the five steps to set that up, an example alert, and the paper run to do first.

Set it up in five steps

  1. 1

    Generate an Alpaca API key

    Sign in at alpaca.markets. In the dashboard, go to Paper Trading or Live Trading, select API Keys, and generate a new key. Copy the key and secret now: the secret is shown once. Keep them out of any shared file.

  2. 2

    Connect Alpaca to Nyria

    Sign in to Nyria, select Integrations, and pick the Alpaca card. Paste the API key and secret. For a paper run, use a Paper Trading key. For live orders, use a Live Trading key from a funded account with the permissions your trades need.

  3. 3

    Create a strategy in Nyria

    Go to My strategies and select Create strategy. Name it and pick TradingView as the alert source. Nyria shows the strategy's webhook URL. Copy it.

  4. 4

    Paste the webhook URL into TradingView

    In TradingView, create a new alert on your chart, indicator or strategy. Open Message, write the alert text (the ticker, the action, and for options the contract) and select Apply. Open Notifications, tick Webhook URL, paste Nyria's strategy URL and select Apply. Webhooks need a paid TradingView plan with two-factor sign-in on.

  5. 5

    Deploy on paper, check the logs

    Back in Nyria, deploy a bot on Alpaca Paper. Let the chart fire a real alert and open the bot's Logs tab. Each alert and the order it caused are recorded. Confirm the ticker, side and quantity match. When they do, deploy a bot on the live Alpaca account.

Alpaca's paper and live accounts have separate keys. Connect the paper key first, and add the live key when you go live.

Watch the setup

How to automate TradingView alerts to Alpaca
Connect Alpaca and build a TradingView strategy. Check the alert format, deploy a bot.
Steps in the video
  1. 0:00Connect Alpaca. Open Integrations and the Alpaca card. Pick Paper or Live and accept. Paste the API key ID and secret from your Alpaca dashboard.
  2. 0:22Create a strategy. Select Create strategy and name it. Then, select your alert source. This example uses TradingView. Pick stocks and a ticker, then create the draft.
  3. 0:50Create the alert in TradingView. Copy the webhook URL and the alert message from the Integration tab. In TradingView, select Message, paste the message and select Apply. Then select Notifications, tick Webhook URL, paste the URL and select Apply.
  4. 2:32Check the format. Select Check format and add an entry and an exit alert. Nyria shows the ticker, side and order it read.
  5. 2:52Deploy a bot. Select Deploy bot, set a budget per entry and pick an account. Nyria Paper is free, so test there first. On your own Alpaca account, pick it on the Account step. Send a sample alert and watch the paper order fill.

A worked example

Stocks, long only. Entries are market orders; exits are market orders on the exit alert.

Entry alert message in TradingView

long AAPL

Exit alert message

exit AAPL long

A bot on the strategy uses a $1,000 budget per entry. The entry alert fires; Nyria reads "long AAPL", checks the latest quote, and sends Alpaca a market order for the number of whole shares $1,000 covers. When the exit fires, Nyria closes whatever AAPL the bot holds. Nothing in the message sets the size: the budget on the bot does. The Logs tab shows the alert text, the order sent and Alpaca's fill.

What Nyria trades at Alpaca

US stocks and ETFs in whole shares, options up to 4 legs, and crypto spot. Nyria sends market and limit orders, as the strategy sets them. Exits come from your exit alerts. Short selling needs a margin account at Alpaca. Stock orders go in during regular market hours; crypto trades around the clock.

Alpaca's working with orders docs cover order types, asset restrictions and account requirements. The Alpaca integration page lists what Nyria specifically places.

Questions

Does TradingView connect to Alpaca directly?
Not for alerts. A TradingView alert can send its message to a URL, but it can't place an order. A receiver such as Nyria reads the message and places the order at Alpaca.
Do I need TradingView's paid plan?
Yes. TradingView sends webhooks on its paid plans only, with two-factor sign-in turned on. Nyria itself is free to test on paper.
What does Nyria trade at Alpaca?
US stocks and ETFs in whole shares, options up to 4 legs, and crypto spot. Exits come from your exit alerts.
Can I test without funding a live Alpaca account?
Yes. Alpaca has a paper trading environment with its own API keys. Use a Paper Trading key in Nyria to test all the way through without real money.
What if the alert fires but no order appears?
Open the Logs tab on the bot. Each alert Nyria received is logged with the reason it placed or refused an order. Common reasons: the bot is paused, the Budget per entry is below the price of one share, or the alert names no ticker.

Test on Alpaca Paper first

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