TradingView Webhooks

Using ChatGPT with the FutuCopy webhook reference file

If you want help building your TradingView alert message, Pine Script strategy, or webhook JSON, you can use ChatGPT or another AI assistant with FutuCopy's LLM-friendly reference file.

Copy this link and give it to ChatGPT:

https://futucopy.com/tradingview-webhooks  

Then ask a specific question, such as:

  • "Use this FutuCopy webhook spec to create a TradingView alert message for a market order using strategy placeholders."
  • "Use this FutuCopy webhook spec to convert my Pine Script strategy into a FutuCopy webhook alert."
  • "Use this FutuCopy webhook spec to explain why my JSON message is failing."
  • "Use this FutuCopy webhook spec to create a stop order with stop loss and profit target ticks."

The reference file is written for AI assistants and includes all supported fields, examples, validation rules, common errors, and TradingView placeholder notes.


What TradingView Webhooks Do

TradingView Webhooks let TradingView alerts send trade instructions to FutuCopy. FutuCopy receives the alert, checks your webhook token, reads the JSON message, and then places or flattens orders on the selected trade copy leader.


If copy trading is enabled for that leader, follower accounts will also receive copied orders according to your trade copy configuration.


Important: Webhook messages can place real orders. Always verify the leader ID, action, order type, quantity, and price before enabling a live TradingView alert.


Security Notes

  • Your webhook URL contains a secret token. Treat it like a password.
  • The public FutuCopy webhook endpoint is designed to receive calls from TradingView's webhook delivery servers only.
  • If you expose your webhook URL in a screenshot, public script, shared document, or chat, rotate your webhook token immediately.
  • Rotating a token invalidates the old webhook URL. After rotating, update every TradingView alert that used the old URL.
  • Deleting a token disables webhook access until you generate a new token.

Requirements

  • A configured trade copy leader with an assigned leader account.
  • A TradingView plan that supports webhooks.
  • Two-factor authentication enabled on your TradingView account.
  • A TradingView strategy alert if you want to use placeholders such as {{strategy.order.action}}    and {{strategy.order.contracts}}   .

Step 1: Create or Copy Your FutuCopy Webhook URL

  • Open FutuCopy.
  • Go to the Webhooks page.
  • If you do not have a webhook token, click Generate Webhook Token.
  • Copy the full Webhook URL.

Your webhook URL will look like this:

https://webhook.futucopy.com/webhook/YOUR_WEBHOOK_TOKEN   

Step 2: Find Your Leader ID

The webhook message needs to know which FutuCopy trade copy leader it should control. On the Webhooks page, look for the Configured Leaders table.

The table shows eligible leaders that have an assigned leader account. Use the value in the ID column as leader_id    in your webhook JSON.


If you do not see any leaders, open the Trade Copy page and configure a leader with an assigned leader account first.


Bracket TP/SL Copying And Suspended Orders


Stop loss and profit target fields create attached bracket/OSO child orders if the leader brokerage is Tradovate. Tradovate initially reports these attached child orders in Suspended  status until the parent entry order fills.


"Suspended" is a Tradovate-specific order state and is not supported by other brokerages. FutuCopy is brokerage agnostic, so it does not copy Suspended  TP/SL child orders to follower accounts. The leader entry order is still copied according to the user's copy configuration. After the leader entry fills and Tradovate transitions the attached TP/SL child orders from Suspended  to Live /Working , those child orders become eligible to copy to followers.


Step 3: Create a TradingView Alert

  • Open TradingView.
  • Open the chart and strategy you want to use.
  • Create an alert.
  • For the alert condition, choose your strategy.
  • Enable webhook delivery in the alert notification settings.
  • Paste your FutuCopy webhook URL into the TradingView webhook URL field.
  • Paste your JSON alert message into the TradingView Message field.
  • Save the alert.


    TradingView Documentation


Important: Manual Alerts vs Strategy Alerts

TradingView strategy placeholders such as {{strategy.order.action}}   , {{strategy.order.contracts}}   , and {{strategy.order.price}}    only work in strategy order-fill alerts.

If you test with a simple manual price alert, TradingView may send the placeholders literally instead of replacing them with real values. For example, FutuCopy might receive "{{strategy.order.action}}"    instead of "buy"   .

For strategy placeholders, use a TradingView strategy and create an order-fill alert.


Simplest Possible Pine Script Test

Use this small TradingView strategy to test {{strategy.order.action}}    and {{strategy.order.contracts}}   .

//@version=6   

strategy("FutuCopy Placeholder Test", overlay=true, process_orders_on_close=true)   


if bar_index % 2 == 0   

strategy.entry("Test Long", strategy.long, qty=1)   

else   

strategy.close("Test Long")   

How to use it:

  • Open TradingView's Pine Editor.
  • Paste the script.
  • Click Add to chart.
  • Create an alert from the strategy.
  • Choose the strategy order-fill alert option.
  • Use your FutuCopy webhook URL.
  • Use the JSON message below.

Test Alert Message

{   

"action": "{{strategy.order.action}}",   

"contracts": {{strategy.order.contracts}},   

"leader_id": 1496,   

"order_type": "market"   

}   

Replace 1496    with your actual leader ID from the FutuCopy Webhooks page.


FutuCopy Alert Message Builder

The FutuCopy Webhooks page includes an Alert Message Builder. It can generate webhook JSON in two modes:

  • Manual: Builds a message with fixed values such as "buy"   , 1   , and a selected leader ID. Manual messages can be tested directly from the FutuCopy Webhooks page.
  • Pine Script: Builds a message using TradingView placeholders such as {{strategy.order.action}}    and {{strategy.order.contracts}}   . Pine Script placeholder messages must be tested from TradingView, because TradingView is what replaces the placeholders.

Supported Webhook Actions

FutuCopy supports three main webhook operations:

  • Place Order: Use "action": "buy"    or "action": "sell"   .
  • Flatten One Leader: Use "action": "flatten"   .
  • Flatten All: Use "action": "flatten_all"   .


Supported JSON Fields

action

Required: yes

Type: text

Supported values: buy   , sell   , flatten   , flatten_leader   , flatten_all  

Use buy    or sell    to place orders. Use flatten    to flatten one leader. Use flatten_all    to flatten all.

contracts

Required: yes for buy    and sell   

Type: whole number

Must be greater than zero. This is ignored for flatten actions.

leader_id

Required: yes for buy   , sell   , and flatten   

Type: whole number

Use the ID from the Configured Leaders table on the FutuCopy Webhooks page. It is not required for flatten_all   .

order_type

Required: no

Type: text

Default: market   

Supported values: market   , limit   , stop   

Also accepted: mkt   , lmt   , stp   , 1   , 2   , 3   

The camelCase field orderType    is also accepted.

price

Required: yes for limit    and stop    orders

Required: no for market    orders

Type: decimal number or numeric text

Must be greater than zero when used. Do not include price    on market orders.

stop_loss_ticks

Required: no

Type: whole number

Adds a stop loss by tick distance from entry. Must be at least 1. Do not use this together with stop_loss_price   .

stop_loss_price

Required: no

Type: decimal number or numeric text

Adds an absolute stop loss price. Must be greater than zero. Do not use this together with stop_loss_ticks   . The camelCase field stopLossPrice    is also accepted.

profit_target_ticks

Required: no

Type: whole number

Adds a profit target by tick distance from entry. Must be at least 1. Do not use this together with profit_target_price   .

profit_target_price

Required: no

Type: decimal number or numeric text

Adds an absolute profit target price. Must be greater than zero. Do not use this together with profit_target_ticks   . The camelCase field profitTargetPrice    is also accepted.

Bracket Order Note

Brackets are supported for Tradovate leaders only. Use stop loss and profit target fields only where supported by your leader connection.

Market Order Example: Manual

{   

"action": "buy",   

"contracts": 1,   

"leader_id": 1496,   

"order_type": "market"   

}   

Market Order Example: TradingView Strategy Placeholders

{   

"action": "{{strategy.order.action}}",   

"contracts": {{strategy.order.contracts}},   

"leader_id": 1496,   

"order_type": "market"   

}   

Limit Order Example

{   

"action": "buy",   

"contracts": 1,   

"leader_id": 1496,   

"order_type": "limit",   

"price": 7235   

}   

Stop Order Example

{   

"action": "buy",   

"contracts": 1,   

"leader_id": 1496,   

"order_type": "stop",   

"price": 7235   

}   

Stop Order Example With TradingView Price Placeholder

{   

"action": "{{strategy.order.action}}",   

"contracts": {{strategy.order.contracts}},   

"leader_id": 1496,   

"order_type": "stop",   

"price": {{strategy.order.price}}   

}   

Important Note About Price

{{strategy.order.price}}    is TradingView's strategy order execution price. If you need a Pine Script-calculated stop or limit level before the order fills, build the JSON message in Pine Script using alert_message   , then put {{strategy.order.alert_message}}    in the TradingView alert Message field.

Bracket Example With Tick-Based Stop Loss and Profit Target

{   

"action": "{{strategy.order.action}}",   

"contracts": {{strategy.order.contracts}},   

"leader_id": 1496,   

"order_type": "market",   

"stop_loss_ticks": 40,   

"profit_target_ticks": 40   

}   

Bracket Example With Absolute Stop Loss and Profit Target Prices

{   

"action": "buy",   

"contracts": 1,   

"leader_id": 1496,   

"order_type": "market",   

"stop_loss_price": 7210.25,   

"profit_target_price": 7260.25   

}   

Flatten One Leader Example

{   

"action": "flatten",   

"leader_id": 1496   

}   

Flatten All Example

{   

"action": "flatten_all"   

}   

Using Pine Script alert_message for Advanced Messages

For simple strategy orders, the normal TradingView placeholders are usually enough:

  • {{strategy.order.action}}   
  • {{strategy.order.contracts}}   
  • {{strategy.order.price}}   

If you need Pine Script to calculate custom values, use strategy.order.alert_message   .

In the TradingView alert Message field, use:

{{strategy.order.alert_message}}   

Then build the JSON in Pine Script and pass it to the order command's alert_message    parameter.

Example concept:

//@version=6   

strategy("FutuCopy Custom Alert Message Example", overlay=true)   


float myStopPrice = close + syminfo.mintick * 4   

string msg = '{"action":"buy","contracts":1,"leader_id":1496,"order_type":"stop","price":' + str.tostring(myStopPrice, format.mintick) + '}'   


if barstate.isconfirmed   

strategy.entry("Stop Long", strategy.long, qty=1, stop=myStopPrice, alert_message=msg)   

Make sure the final message TradingView sends is valid JSON.


Testing From FutuCopy

The Webhooks page includes a Test Webhook button. This sends the exact message shown in the Alert Message Builder through your webhook URL.

Use the built-in test for Manual messages only. Pine Script placeholders are replaced by TradingView, so FutuCopy cannot fill them during a manual test.

Warning: The built-in test sends a real webhook. Order messages can place real orders on the selected leader account, and flatten messages can close positions.


Viewing Webhook Call History

After a webhook is received, it appears in the Webhook Call History table on the Webhooks page.

The table includes:

  • Time
  • Request body
  • Status
  • Response message

You can refresh the table or export the call history to CSV.


Common Response Messages and Errors

Invalid webhook token format.

The webhook token in the URL is missing, malformed, or not in the expected format. Copy the full webhook URL again from the Webhooks page.

Invalid webhook token.

The token does not match an active FutuCopy webhook token. The token may have been rotated or deleted. Copy the current URL from the Webhooks page.

Action must be 'buy', 'sell', 'flatten', or 'flatten_all'.

The action    field is missing or not supported.

leader_id is required.

Add a valid leader_id    from the Configured Leaders table. This is not required for flatten_all   .

Contracts must be greater than zero.

For buy and sell orders, contracts    must be a positive whole number.

Order type must be 'market', 'limit', or 'stop'.

Use one of the supported order types.

Price is required and must be greater than zero for limit and stop orders.

Add price    for limit and stop orders.

Price can only be used with limit and stop orders.

Remove price    from market orders.

Use either stop_loss_ticks or stop_loss_price, not both.

Choose either tick-based stop loss or absolute stop loss price.

Use either profit_target_ticks or profit_target_price, not both.

Choose either tick-based profit target or absolute profit target price.

Trade copy leader with ID not found.

The leader_id    does not match an eligible leader for your account. Confirm the ID on the Webhooks page.

Leader has no account assigned.

The selected leader does not have a leader account assigned. Configure the leader account on the Trade Copy page.

Too many webhook requests.

The webhook was rate limited. Reduce alert frequency and retry after the indicated delay.



Troubleshooting


Bracket TP/SL orders are not being copied

Check whether the attached TP/SL child orders are still in "Suspended" status.

FutuCopy is brokerage agnostic and does not copy "Suspended" orders because that state is Tradovate-specific.

Once the leader entry fills and the child orders transition to "Live"/"Working", they will be copied to followers according to your copy configuration.


My placeholders are not being replaced.

Make sure you are using a TradingView strategy order-fill alert. Simple manual alerts do not populate strategy placeholders.




My JSON is invalid.

Check commas, quotes, and numeric placeholders. The most common format is:

"action": "{{strategy.order.action}}",   

"contracts": {{strategy.order.contracts}}   

Notice that action    is quoted because it becomes text, while contracts    is not quoted because it becomes a number.


My market order is rejected.

Remove the price    field. FutuCopy only accepts price    for limit and stop orders.


My limit or stop order is rejected.

Add a positive price    value.


My leader ID is rejected.

Open the FutuCopy Webhooks page and use an ID from the Configured Leaders table. The leader must have an assigned leader account.


I changed my Pine Script but the alert still behaves like the old version.

TradingView alerts keep a snapshot of the script and chart settings from when the alert was created. Delete and recreate the alert after changing the script.


Can I test from Postman, curl, Zapier, Make, or another app?

The public webhook endpoint is intended for TradingView server delivery only. Use TradingView for live webhook delivery, or use the built-in Test Webhook button on the FutuCopy Webhooks page for manual testing.


Best Practices

  • Start with one contract while testing.
  • Use the smallest safe size for the account.
  • Confirm the leader ID before turning on a live alert.
  • Use the Webhook Call History after every test.
  • Rotate the token if it is exposed.
  • Recreate TradingView alerts after changing Pine Script.
  • Do not include both tick-based and price-based stop loss fields in the same message.
  • Do not include both tick-based and price-based profit target fields in the same message.

Quick Copy/Paste Templates

Strategy Market Order

{   

"action": "{{strategy.order.action}}",   

"contracts": {{strategy.order.contracts}},   

"leader_id": 1496,   

"order_type": "market"   

}   

Strategy Market Order With Brackets

{   

"action": "{{strategy.order.action}}",   

"contracts": {{strategy.order.contracts}},   

"leader_id": 1496,   

"order_type": "market",   

"stop_loss_ticks": 40,   

"profit_target_ticks": 40   

}   

Flatten One Leader

{   

"action": "flatten",   

"leader_id": 1496   

}   

Flatten All

{   

"action": "flatten_all"   

}   

Still need help? Contact Us Contact Us