TradingView Webhook Automation: JSON Template for Crypto Trading
Use this TradingView webhook automation JSON template to send cleaner crypto trade alerts with side, symbol, size, TP/SL, and strategy ID fields.
Most traders start with TradingView alerts as notifications.
Price crosses a level. An indicator flips. A Pine Script strategy prints a signal. TradingView sends a push notification, and the trader still has to open the exchange, choose the pair, set size, place the order, and manage the exit manually.
That is useful, but it is not automation.
TradingView webhook automation is what happens when that alert sends a structured message to an execution system instead. Instead of saying "BTC long now" in a phone notification, the alert sends a JSON payload that a system like Crodl can read, validate, route, and execute.
This guide shows a practical TradingView webhook JSON template for crypto trading, how to use it, and what to avoid before you let any alert touch real capital.
What a TradingView Webhook Does
A TradingView webhook sends an HTTP POST request to a webhook URL when an alert fires. That URL can belong to a trading automation platform, a custom server, a logging system, or a workflow tool.
For crypto traders, the common flow is:
- Your TradingView indicator or strategy creates an alert.
- TradingView sends a webhook request to your automation URL.
- The automation system reads the alert message.
- The system decides what action to take.
- The trade is routed to the connected exchange account.
TradingView supports alert messages as plain text or JSON. If the alert message is valid JSON, TradingView sends it with a JSON content type. That matters because structured JSON is much easier for automation software to validate than a sentence like "buy BTC now".
You can read the official TradingView details in their webhook configuration guide and alert placeholder guide.
Why JSON Is Better Than Plain Text
Plain text alerts are fine for human notifications:
BTC long signal on 1h
But automation needs structure:
- What exchange should receive the order?
- Which symbol should be traded?
- Is this an open, close, long, or short?
- Is size based on margin, position percentage, or asset amount?
- Should TP/SL be attached?
- Which strategy journal should this trade belong to?
JSON gives every answer a field name. That makes the signal easier to validate, easier to log, and easier to debug when something goes wrong.
The Simple Crodl Setup
The cleanest Crodl workflow is still the one covered in our full guide on how to automate crypto trades with TradingView webhooks:
- Connect your exchange API key in Crodl.
- Create an open or close trigger.
- Configure symbol, side, size, TP/SL, and journal settings in Crodl.
- Copy the trigger JSON payload from Crodl.
- In TradingView, set the webhook URL to
https://api.crodl.com/webhooks/trading. - Paste the trigger JSON into the alert Message field.
In that setup, the JSON payload contains the execution rules. Crodl validates the payload, resolves the connected exchange API key through your security_token, and queues the trade asynchronously.
Use the full JSON payload when you want reusable Pine scripts, TradingView alerts, strategy-level journaling, or alert payloads copied from Crodl's Pine library.
TradingView Webhook JSON Template
Start with a small, explicit payload. Do not try to make your first automated alert handle every edge case.
{
"name": "BTC Long",
"allocation_id": "btc-breakout-a1",
"strategy_dashboard_id": "btc-breakout-1h",
"trading_action": "open",
"exchange": "blofin",
"security_token": "your_security_token",
"symbol": "BTC-USDT",
"side": "long",
"order_type": "market",
"margin_mode": "isolated",
"position_mode": "oneway",
"trading_type": "futures",
"leverage_amount": "3",
"quantity_type": "amount",
"quantity_mode": "margin",
"quantity_amount": "25",
"quantity_quote": "USDT",
"opposite_side_close": false,
"alert_id": "btc-breakout-1h-long-{{time}}"
}
This is the basic shape:
trading_actionsays whether this alert opens or closes risk.exchangetells Crodl where the trade should route.security_tokenauthenticates the webhook and resolves the connected Crodl API key.symboluses the exchange-native pair format, such asBTC-USDT.sidesays long, short, close_long, or close_short.order_typekeeps the first version simple with a market order.margin_mode,position_mode, andleverage_amountdefine the futures execution setup.quantity_type,quantity_mode, andquantity_amountdefine sizing.allocation_idlets closes target one strategy bucket instead of the full net position.strategy_dashboard_idkeeps the trade attached to the right journal.alert_idgives Crodl an idempotency key so repeated webhook fires do not duplicate the same trade.
Replace the sample values with your own Crodl exchange, security token, symbol, sizing rule, allocation ID, and strategy ID before using the payload.
Long Entry Template
Use this when the alert should open a long position.
{
"name": "BTC Long",
"allocation_id": "btc-breakout-a1",
"strategy_dashboard_id": "btc-breakout-1h-long",
"trading_action": "open",
"exchange": "blofin",
"security_token": "your_security_token",
"symbol": "BTC-USDT",
"side": "long",
"order_type": "market",
"margin_mode": "isolated",
"position_mode": "oneway",
"trading_type": "futures",
"leverage_amount": "3",
"quantity_type": "amount",
"quantity_mode": "margin",
"quantity_amount": "25",
"quantity_quote": "USDT",
"opposite_side_close": false,
"take_profit_type": "market",
"take_profit_mode": "percentage",
"take_profit_trigger_price": "2",
"stop_loss_type": "market",
"stop_loss_mode": "percentage",
"stop_loss_trigger_price": "0.8",
"alert_id": "btc-breakout-1h-long-{{time}}"
}
The important part is not the exact 2% take profit or 0.8% stop loss. Those are examples. The important part is that the alert sends a complete trade intent:
- direction
- size
- risk controls
- journal grouping
- signal metadata
If your strategy has not been tested, do not automate it with meaningful size. Start with demo trading or the smallest live size your exchange allows.
Short Entry Template
Short entries use the same structure, but the side changes.
{
"name": "BTC Short",
"allocation_id": "btc-breakout-a1-short",
"strategy_dashboard_id": "btc-breakout-1h-short",
"trading_action": "open",
"exchange": "blofin",
"security_token": "your_security_token",
"symbol": "BTC-USDT",
"side": "short",
"order_type": "market",
"margin_mode": "isolated",
"position_mode": "oneway",
"trading_type": "futures",
"leverage_amount": "3",
"quantity_type": "amount",
"quantity_mode": "margin",
"quantity_amount": "25",
"quantity_quote": "USDT",
"opposite_side_close": false,
"take_profit_type": "market",
"take_profit_mode": "percentage",
"take_profit_trigger_price": "2",
"stop_loss_type": "market",
"stop_loss_mode": "percentage",
"stop_loss_trigger_price": "0.8",
"alert_id": "btc-breakout-1h-short-{{time}}"
}
Keep long and short alerts separate when you are starting out. It is easier to audit two simple alerts than one complex alert that tries to infer too much.
Close Position Template
Closing risk should be explicit. If your alert is meant to close a long, send a close-long instruction. If it is meant to close a short, send a close-short instruction.
{
"name": "BTC Close Long",
"allocation_id": "btc-breakout-a1",
"strategy_dashboard_id": "btc-breakout-1h-long",
"trading_action": "close",
"exchange": "blofin",
"security_token": "your_security_token",
"symbol": "BTC-USDT",
"side": "close_long",
"order_type": "market",
"trading_type": "futures",
"quantity_type": "percentage",
"quantity_amount": "100",
"cancel_unfilled": "disabled",
"alert_id": "btc-breakout-1h-close-long-{{time}}"
}
For a short close, change side to close_short and reuse the matching strategy_dashboard_id.
That ID matters. If your entry and exit use different strategy IDs, your journal may split one trade into two unrelated events. We covered why this matters in why most trading journals break.
TradingView Placeholders Worth Using
TradingView placeholders are variables that get replaced when the alert fires.
The most useful ones for webhook automation are:
| Placeholder | What it sends |
|---|---|
{{ticker}} | The chart symbol |
{{exchange}} | The TradingView data exchange |
{{interval}} | The chart timeframe where the alert was created |
{{close}} | The close price of the triggering bar |
{{time}} | The triggering bar time |
{{timenow}} | The time the alert fired |
{{volume}} | Volume on the triggering bar |
Use placeholders carefully. Crodl expects exchange-native symbols, so {{ticker}} is only safe when the TradingView ticker already matches the target exchange symbol format. For example, OKX perpetuals should use the full instId format such as BTC-USDT-SWAP.
Do not rely on placeholders to fix bad risk settings. Position size, leverage, stop loss, and take profit rules should be deliberate.
Pine Script Strategy Alerts
If you are using a Pine Script strategy instead of a basic indicator alert, TradingView also supports strategy placeholders such as order action, order size, and order price.
A strategy-style payload can look like this:
{
"name": "BTC Pine Long",
"allocation_id": "pine-breakout-v1-long",
"strategy_dashboard_id": "pine-breakout-v1",
"trading_action": "open",
"exchange": "blofin",
"security_token": "your_security_token",
"symbol": "BTC-USDT",
"side": "long",
"order_type": "market",
"margin_mode": "isolated",
"position_mode": "oneway",
"trading_type": "futures",
"leverage_amount": "3",
"quantity_type": "amount",
"quantity_mode": "margin",
"quantity_amount": "25",
"quantity_quote": "USDT",
"alert_id": "pine-breakout-v1-{{strategy.order.id}}-{{time}}"
}
Be careful with this pattern. TradingView strategy placeholders may send values like buy or sell, while Crodl expects long, short, close_long, or close_short. Do not paste {{strategy.order.action}} directly into side unless your Pine Script maps it to Crodl's side values first.
For most traders, separate long, short, close-long, and close-short alerts are easier to reason about.
What Not to Put in a Webhook Message
Crodl's webhook payload requires a security_token. That token is not your exchange API secret, but it does grant trading access through Crodl, so treat it like a password and paste it only into your private TradingView alert.
Do not add any extra credentials beyond the Crodl security_token.
Do not include:
- exchange API key
- exchange API secret
- exchange passphrase
- Crodl password
- email password
- seed phrase
- private key
- personal login credentials
TradingView also warns against sending credentials through webhook messages. Treat the copied Crodl payload as execution-capable material. If someone has your security_token and a valid payload, they may be able to create unwanted orders.
The safe pattern is:
- store exchange credentials inside Crodl
- paste only the Crodl
security_tokeninto the private TradingView alert payload - use API keys with the minimum permissions needed
- avoid withdrawal permissions on trading API keys
- keep copied payloads private
- rotate your security token or exchange API key if either is exposed
Common Webhook Automation Mistakes
Mistake 1: Starting with too much size
Automation removes hesitation. That is good when the system is tested and bad when the logic is wrong.
Start with demo trading or tiny live size. Verify the first several alerts manually before scaling.
Mistake 2: Letting one alert do everything
One mega-alert that can open long, open short, close long, close short, reverse, pyramid, and resize sounds efficient. It is usually harder to debug.
Start with one alert per action.
Mistake 3: No strategy ID
Without a stable strategy_dashboard_id, your journal has to infer which entry and exit belong together.
That breaks down quickly when you run multiple strategies on the same symbol or trade across multiple exchanges.
Mistake 4: No TP/SL plan
An automated entry without an exit plan is only half a system.
If the setup needs a stop loss, define it before the alert goes live. If the setup needs manual review, do not pretend it is fully automated.
Mistake 5: Forgetting exchange differences
Symbols, minimum order sizes, leverage limits, margin modes, and liquidity differ by exchange. A payload that works on one exchange may need adjustment on another.
If you trade across venues, read our guide on why trade on multiple crypto exchanges and keep your symbol mapping clean.
Testing Checklist Before Going Live
Before you let a TradingView webhook trade with real size, check:
- The JSON is valid.
- The
security_tokenis present and private. - The exchange API key has no withdrawal permission.
- The symbol maps correctly on the target exchange.
- Long alerts open long positions.
- Short alerts open short positions.
- Close-long alerts close long positions.
- Close-short alerts close short positions.
- Position size is correct.
- Leverage is correct.
- TP/SL rules behave as expected.
- The trade lands in the correct strategy journal.
- Errors are visible in your execution history.
Only increase size after the workflow has produced the expected orders under real market conditions.
Frequently Asked Questions
Do I need JSON for TradingView webhook automation?
Yes for Crodl's documented TradingView endpoint. Set TradingView's Webhook URL to https://api.crodl.com/webhooks/trading, then paste the Crodl trigger JSON into the alert Message field. You do not have to write the JSON by hand if you copy the payload from Crodl.
Does TradingView send JSON automatically?
TradingView sends the alert message you enter. If that message is valid JSON, TradingView sends it as JSON. If the message is plain text, it is sent as plain text.
Can I use {{ticker}} for every exchange?
Use it carefully. {{ticker}} comes from the TradingView chart symbol, and your execution exchange may use a slightly different symbol format. Test symbol mapping before going live.
Should I include my exchange API key secret in the webhook?
No. Never put exchange API keys, exchange secrets, passwords, passphrases, seed phrases, or private keys in a webhook message. Crodl's security_token is the only secret-like value the documented webhook payload needs, and it should be kept private.
Should one alert open and close trades?
Usually not at first. Separate alerts for long entry, short entry, long close, and short close are easier to test and audit. Combine logic only after the simple version works reliably.
Final Thought
TradingView webhook automation is not just about sending an alert to a bot.
The quality of the payload matters.
A good webhook message tells the execution system exactly what to do, how much risk to take, how to group the trade in the journal, and enough context to debug the signal later.
Start simple. Keep the JSON explicit. Use stable strategy IDs. Test the full path before increasing size.
If you are still building the rest of the workflow, start with our guide to TradingView webhook automation, then tighten your risk process with risk management basics every crypto trader should know.
This content is for educational purposes only and does not constitute financial advice. Cryptocurrency trading involves significant risk of loss. Past performance does not guarantee future results.
Ready to automate your trading?
Connect your exchange, set up automations, and start trading smarter — all from one platform.
Start Trading Free