What This Guide Covers
If you have a Pine Script strategy on TradingView that generates good signals, you can automate it. Instead of watching alerts and manually placing trades, a webhook bot receives your Pine Script signals and executes them instantly on your exchange.
The flow: Pine Script fires alert → TradingView sends webhook → fomoed receives it → bot places trade on your exchange. Fully automated, no manual intervention needed.
How Pine Script Alerts Work
TradingView alerts can trigger on any condition in your Pine Script code. When you use alertcondition() or the newer alert() function, TradingView evaluates your conditions on their servers and fires the alert whenever the condition becomes true.
The key feature: TradingView can send a webhook (an HTTP POST request to a URL) whenever an alert fires. This webhook carries a payload — a message you define — that contains the trade information.
Step 1: Prepare Your Pine Script
Your Pine Script needs to output clear, parseable signals. The simplest approach uses the alert() function with a JSON payload:
//@version=5
strategy("My Strategy", overlay=true)
// Your entry/exit logic
longCondition = ta.crossover(ta.sma(close, 20), ta.sma(close, 50))
shortCondition = ta.crossunder(ta.sma(close, 20), ta.sma(close, 50))
if (longCondition)
strategy.entry("Long", strategy.long)
alert('{"action": "buy", "symbol": "' + syminfo.ticker + '", "price": ' + str.tostring(close) + '}', alert.freq_once_per_bar_close)
if (shortCondition)
strategy.close("Long")
alert('{"action": "sell", "symbol": "' + syminfo.ticker + '", "price": ' + str.tostring(close) + '}', alert.freq_once_per_bar_close)
Key points:
- Use
alert.freq_once_per_bar_closeto avoid multiple signals per bar - Include the action (buy/sell), symbol, and current price in your payload
- Use valid JSON format so the receiving bot can parse it cleanly
Step 2: Create a Webhook Bot on fomoed
In your fomoed dashboard, create a new bot and select the Webhook strategy. This generates a unique webhook URL for your bot — something like:
https://api.fomoed.com/webhook/bot/abc123xyz
This URL is your bot's "ears" — any properly formatted POST request sent to it triggers trade execution. Keep it private — anyone with the URL can send signals to your bot.
Webhook Bot Configuration
Configure these settings in the webhook bot setup:
| Setting | Purpose | Example |
|---|---|---|
| Exchange | Where trades execute | Hyperliquid, Binance, Bybit |
| Pair | What to trade (or dynamic from payload) | BTC/USDC |
| Position size | How much per signal | $500 or 2% of balance |
| Leverage | Leverage for perp trades | 3x |
| Take profit | Auto TP on entries | 2% |
| Stop loss | Auto SL on entries | 1% |
Step 3: Connect TradingView to Your Webhook URL
- On TradingView, add your Pine Script strategy to a chart
- Right-click on the strategy → "Add Alert"
- In the alert dialog, set the condition to your strategy
- Under "Notifications," enable Webhook URL
- Paste your fomoed webhook URL
- In the "Message" field, define your payload format
- Set expiration to "Open-ended" for continuous operation
- Click "Create"
The Alert Message (Payload)
The message field is what gets sent to your webhook URL. Use this format for fomoed compatibility:
{
"action": "{{strategy.order.action}}",
"symbol": "{{ticker}}",
"price": {{close}},
"quantity": "{{strategy.order.contracts}}"
}TradingView replaces the {{placeholders}} with actual values when the alert fires. The result is a clean JSON object your webhook bot can parse and execute.
Step 4: Test the Connection
Before relying on your webhook bot for real trades:
- Set the bot to paper trading mode
- Fire a test alert from TradingView (use the "Test" button in alert settings)
- Check your fomoed dashboard — you should see the signal received
- Verify the paper trade was placed correctly (right pair, right direction, right size)
If the test fails, common issues include:
- Malformed JSON in the alert message (check brackets and quotes)
- Incorrect webhook URL (copy-paste error)
- TradingView plan doesn't support webhooks (requires paid plan)
Step 5: Go Live
Once paper tests confirm the connection works:
- Switch your webhook bot from paper to live mode
- Keep your TradingView alert active (it's already pointing to the right URL)
- The next signal from your Pine Script strategy will execute a real trade
Payload Format Reference
fomoed webhook bots accept these fields:
| Field | Required | Values |
|---|---|---|
| action | Yes | "buy", "sell", "close" |
| symbol | No (uses bot default) | "BTCUSDC", "ETHUSDC" |
| price | No | Execution price (market if omitted) |
| quantity | No (uses bot default) | Position size |
| takeProfit | No (uses bot default) | TP price or percentage |
| stopLoss | No (uses bot default) | SL price or percentage |
Advanced: Multiple Strategies, One Bot
You can point multiple Pine Script alerts to the same webhook bot — useful if you have signals on different timeframes or different conditions that all trade the same pair. The bot processes each signal independently.
Alternatively, create separate webhook bots for separate strategies, each with their own risk parameters. This gives you independent PnL tracking and risk management per strategy.
Advanced: Custom Alert Conditions
Beyond basic long/short signals, you can send more nuanced payloads:
- Partial closes:
{"action": "sell", "quantity": "50%"} - Trailing activation:
{"action": "buy", "trailingStop": "2%"} - Multiple TPs: Define in the bot config; webhook just triggers entry
TradingView Plan Requirements
One important note: TradingView webhooks require a paid TradingView plan (Pro, Pro+, or Premium). The free TradingView plan doesn't support webhook notifications — only on-screen and email alerts.
However, once you have a TradingView plan, the fomoed webhook bot itself is completely free. No additional subscription needed on the execution side.
Troubleshooting Common Issues
- "Webhook failed" in TradingView — check that the URL is correct and the fomoed bot is active
- Signal received but no trade — verify the payload format matches expected fields; check bot is in live mode
- Duplicate trades — use
alert.freq_once_per_bar_closeto prevent multiple signals per bar - Delayed execution — normal for 1-3 second delay; ensure your strategy accounts for this on fast timeframes
Next Steps
For more detailed webhook bot configurations, read our TradingView webhook auto-trade guide. For a broader overview of webhook strategies and advanced payload handling, check our webhook bots comprehensive guide.
The combination of Pine Script's analytical power and fomoed's execution infrastructure means you can build sophisticated strategies in TradingView and execute them automatically — for free.
Ready to automate your Pine Script strategy? Create your free fomoed account, set up a webhook bot, and connect your TradingView alerts in minutes.


