DocsTradingView Automation
Documentation

TradingView Automation

Connect TradingView alerts, browser tests, and external API tools to your platform using webhook execution, builder-compatible payloads, and copy-ready integration examples.

Overview

TradingView Automation is more than a webhook field. It is a complete execution flow where you choose the destination platform, bind one symbol, define the signal channel and signal source, configure risk and runtime protection, then copy a webhook endpoint that you can call from TradingView, a mobile browser, ReqBin, Python, MQL4, MQL5, or C++.

Webhook-first design

TradingView alerts, scripts, external tools, and manual tests can all target the same generated webhook endpoint.

One bot, one symbol

Keeping one symbol per bot makes execution, debugging, and risk isolation much easier.

Builder-compatible payloads

The same action syntax works across GET, POST, TradingView alerts, ReqBin, Python, C++, MQL4, and MQL5.

Risk-aware runtime

Spread filters, drawdown, DCA, time windows, stop loss, trailing, and deviation control belong in the same operating flow.

Copy-ready integration

You can use direct copy-paste examples instead of relying only on generic explanations.

Multi-language examples

This page includes ready examples for Pine Script, Python, MQL4, MQL5, and C++.

Test before go-live

Before you connect live TradingView alerts, validate your bot from the browser and from a POST tool.

Quick Start

1
Create or open your Strategy Hub bot.
2
Select the exact destination platform/account.
3
Choose one symbol only for the bot.
4
Set the signal channel to Webhook + API if the bot will receive external requests.
5
Choose the signal source label if you want better tracking.
6
Configure DCA, SL/TP, spread, deviation, trailing, time filters, and drawdown as needed.
7
Save the bot and copy the webhook URL.
8
Run a quick GET or POST test before going live.
9
Only after a successful test, connect TradingView alerts or external scripts.

Create the bot

Choose platform

Always choose the exact target account first. After you save the bot, it becomes tied to that platform and symbol scope. This makes your automation cleaner, more predictable, and easier to debug.

TradingView Bot Configuration
Documentation mirror of the real bot form.
Copy · MT5
XAUUSD London Breakout
Webhook + API only
TradingView
XAUUSD
Enable DCA strategy
ON
Negative
3
0.10
Order 1
Size: 0.10
Step: 300
TP: 500
Order 2
Size: 0.12
Step: 450
TP: 650
Order 3
Size: 0.16
Step:
TP: 800
30
120
10
Money management
500
300

Parameters reference

Platform
select
Key: platformId • Required

The destination trading account/platform that will receive the execution.

Copy · MT5
Bot name
text
Key: name • Required

Friendly bot name used for identification and management.

XAUUSD London Breakout
Signal channel
enum
Key: signalChannel • Required

Controls which execution sources are accepted.

webhook_api | manual | all
Most automation flows work best with Webhook + API.
Signal source
enum
Key: signalSource • Optional

Optional label describing where the signal came from.

tradingview, postman, external_api, chatgpt, gemini
Symbol
single-select
Key: symbol • Required

Your bot should target one exact symbol.

XAUUSD
Enable DCA
boolean
Key: allowDca • Optional

Enable averaging logic for the bot.

DCA type
enum
Key: DCAType • Optional

Defines averaging direction behavior.

Negative | Positive | Both
Max open trades
integer
Key: maxOpenTrades • Optional

Maximum open trades allowed for the cycle.

3
Max price deviation
integer
Key: priceDeviation • Optional

Maximum distance allowed between incoming signal price and broker price.

30
Max spread
integer
Key: maxSpread • Optional

Maximum spread allowed before execution is blocked.

150
Allow Take Profit
boolean
Key: allowTakeProfit • Optional

Enable TP handling for the bot.

Allow Stop Loss
boolean
Key: allowStopLoss • Optional

Enable SL handling for the bot.

Stop Loss / DCA step
decimal
Key: stopLoss • Optional

Used as Stop Loss normally, or DCA step when DCA is enabled.

300
Take Profit
decimal
Key: takeProfit • Optional

Take Profit value in points.

500
Trailing mode
boolean
Key: trailingMode • Optional

Enable trailing logic.

Trailing step
decimal
Key: trailingStep • Optional

Trailing step distance.

100
Trailing stop loss distance
decimal
Key: stopLossDistance • Optional

Distance used by trailing stop logic.

250
Max drawdown %
percent
Key: maxDrawdown • Optional

Maximum allowed drawdown percentage.

10
Active from
time
Key: activeFrom • Optional

Bot start time in HH:mm format.

09:00
Active to
time
Key: activeTo • Optional

Bot stop time in HH:mm format.

18:30
Close before weekend
boolean
Key: closeBeforeWeekend • Optional

Optional rule to flatten positions before weekend.

Active status
boolean
Key: isActive • Optional

Enable or disable runtime execution.

Payload builder

The builder generates the same payload syntax used by browser tests, POST tools, TradingView alerts, and external scripts. You can copy the generated URL or body exactly as shown and send it immediately.

Signal Builder
ACTION, PARAM1=VALUE1, PARAM2=VALUE2...
1) Action
Choose what the signal should do.
BUY
BUY — Open a long position at market price.
2) Parameters
VOL
0.10
SL
250
TP
500
TPSLType
PIPS
COMMENT
AI_XAU_BOT
Target & Request
POST
XAUUSD Trend Bot
TradingView
Generated body
BUY, VOL=0.10, SL=250, TP=500, TPSLType=PIPS, COMMENT=AI_XAU_BOT

Supported payload style

ACTION, PARAM1=VALUE1, PARAM2=VALUE2, PARAM3=VALUE3
BUY, VOL=0.10, SL=250, TP=500, TPSLType=PIPS
SELL, RISK=1.5, SL=180, TP=360, TPSLType=PIPS
BUYSTOP, PRICE=2050.00, VOL=0.05, SL=15, TP=30, TPSLType=PIPS
CLOSE, TICKET=12345678
MODIFY, TICKET=12345678, SL=20, TP=40, TPSLType=PIPS
CLOSEALL, COMMENT=FLAT_NOW

Testing from mobile and tools

Before you connect TradingView, always run at least one manual test. The two easiest methods are a direct GET request from your browser and a POST request from a tool such as ReqBin. If both tests succeed, your bot is ready for TradingView alerts or external script integration.

Method 1 — Test from phone browser using GET
Fastest method. No app installation needed.
1
Open Strategy Hub Builder and switch method to GET.
2
Choose the bot and optional signal source.
3
Copy the generated URL using Copy URL.
4
Open any mobile browser and paste the full URL in the address bar.
5
Press Enter / Go.
6
If the bot and account are configured correctly, you should receive a successful JSON response and the signal should be processed.
Method 2 — Test POST using ReqBin
Best when you want to send the exact body generated by the builder.
1
Open the Builder and switch method to POST.
2
Copy URL using Copy URL.
3
Copy body text using Copy Body.
4
Open ReqBin on mobile or desktop.
5
Set method to POST and paste the webhook URL.
6
Choose a plain text body and paste the generated body.
7
Send the request and inspect the JSON response.
8
If the response is successful, the bot is ready for TradingView or script integration.
Method 1 — Quick GET test from phone browser
Open the generated GET URL directly in the browser on your phone. This is the fastest smoke test because it needs no extra tools.
GET
URL
https://api.coneyalgo.xyz/webhooks/fe37f641-67a9-4733-9d4a-c343b4a24bd7?action=BUY&agent=external_api
Expected successful response
{
  "ok": true,
  "traceId": "4df490b6973141fcbdd921d8c8e86d74",
  "botId": "fe37f641-67a9-4733-9d4a-c343b4a24bd7",
  "builtSignal": "BUY,AGENT=external_api",
  "receiver": {
    "state": true,
    "signalId": "f1507cb4-16b8-42a7-a0d6-7b48c6c164cc",
    "message": "PLACED:23000402"
  }
}
Method 2 — POST test using ReqBin
Use an external API testing tool when you want to send a text body exactly like the builder generates.
POST
URL
https://api.coneyalgo.xyz/webhooks/fe37f641-67a9-4733-9d4a-c343b4a24bd7
Body
buy,agent=external_api
Expected successful response
{
  "ok": true,
  "traceId": "b138822642a7403a9724f21180d94162",
  "botId": "fe37f641-67a9-4733-9d4a-c343b4a24bd7",
  "builtSignal": "buy,agent=external_api",
  "receiver": {
    "state": true,
    "signalId": "c38baefd-485a-4e6a-935b-1cf3b5538991",
    "message": "PLACED:23000425"
  }
}

Scripts & integrations

The following examples are designed for direct copy and adaptation. You can paste them into your target environment and usually only need to change the webhook URL, ticket, symbol, or risk values.

TradingView Pine Script examples
Four copy-ready Pine Script alert examples.
Pine example 1 — Simple BUY alert
//@version=5
strategy("ConeyAlgo BUY Example", overlay=true)

longCond = ta.crossover(ta.ema(close, 9), ta.ema(close, 21))

if longCond
    alert("BUY, VOL=0.10, SL=250, TP=500, TPSLType=PIPS, COMMENT=TV_BUY_01", alert.freq_once_per_bar_close)
Send a BUY signal with fixed volume and pip-based SL/TP.
Pine example 2 — Simple SELL alert
//@version=5
strategy("ConeyAlgo SELL Example", overlay=true)

shortCond = ta.crossunder(ta.ema(close, 9), ta.ema(close, 21))

if shortCond
    alert("SELL, VOL=0.10, SL=250, TP=500, TPSLType=PIPS, COMMENT=TV_SELL_01", alert.freq_once_per_bar_close)
Send a SELL signal when the fast EMA crosses below the slow EMA.
Pine example 3 — Close all positions
//@version=5
indicator("ConeyAlgo CloseAll Example", overlay=true)

exitCond = ta.crossunder(ta.rsi(close, 14), 50)

if exitCond
    alert("CLOSEALL, COMMENT=TV_FLAT_ALL", alert.freq_once_per_bar_close)
Useful when your strategy wants to flatten the bot exposure.
Pine example 4 — Pending buy stop
//@version=5
indicator("ConeyAlgo BuyStop Example", overlay=true)

breakout = ta.crossover(close, ta.highest(high, 20)[1])

if breakout
    alert("BUYSTOP, PRICE=2050.00, VOL=0.05, SL=150, TP=300, TPSLType=PIPS, COMMENT=TV_BREAKOUT", alert.freq_once_per_bar_close)
Create a breakout entry using BUYSTOP with explicit price.
Python examples
POST, GET, CLOSE, and MODIFY examples.
Python example 1 — POST market BUY
import requests

url = "https://api.example.com/webhooks/your-bot-id"
body = "BUY, VOL=0.10, SL=250, TP=500, TPSLType=PIPS, COMMENT=PY_BUY"

r = requests.post(
    url,
    data=body.encode("utf-8"),
    headers={"Content-Type": "text/plain"},
    timeout=10,
)

print(r.status_code)
print(r.text)
Send a plain text POST body exactly like the builder output.
Python example 2 — POST close by ticket
import requests

url = "https://api.example.com/webhooks/your-bot-id"
body = "CLOSE, TICKET=12345678, COMMENT=PY_CLOSE_TICKET"

r = requests.post(
    url,
    data=body.encode("utf-8"),
    headers={"Content-Type": "text/plain"},
    timeout=10,
)

print(r.status_code)
print(r.text)
Close a specific trade by its ticket.
Python example 3 — GET request
import requests

url = "https://api.example.com/webhooks/your-bot-id?action=SELL&vol=0.10&sl=250&tp=500&tpsltype=PIPS&agent=external_api"

r = requests.get(url, timeout=10)

print(r.status_code)
print(r.text)
Build the GET URL directly with query parameters.
Python example 4 — Modify SL/TP
import requests

url = "https://api.example.com/webhooks/your-bot-id"
body = "MODIFY, TICKET=12345678, SL=20, TP=40, TPSLType=PIPS, COMMENT=PY_MODIFY"

r = requests.post(
    url,
    data=body.encode("utf-8"),
    headers={"Content-Type": "text/plain"},
    timeout=10,
)

print(r.status_code)
print(r.text)
Update stop loss and take profit for a specific ticket.
MQL4 examples
Four WebRequest-based examples for MT4.
MQL4 example 1 — POST BUY
void SendBuySignal()
{
   string url = "https://api.example.com/webhooks/your-bot-id";
   string body = "BUY, VOL=0.10, SL=250, TP=500, TPSLType=PIPS, COMMENT=MQL4_BUY";
   string headers = "Content-Type: text/plain\r\n";
   char post[];
   StringToCharArray(body, post);
   char result[];
   string response_headers;

   int timeout = 10000;
   int res = WebRequest("POST", url, headers, timeout, post, result, response_headers);

   if(res == -1)
      Print("WebRequest failed: ", GetLastError());
   else
      Print("Response: ", CharArrayToString(result));
}
Send a BUY signal using WebRequest.
MQL4 example 2 — POST SELL
void SendSellSignal()
{
   string url = "https://api.example.com/webhooks/your-bot-id";
   string body = "SELL, VOL=0.10, SL=250, TP=500, TPSLType=PIPS, COMMENT=MQL4_SELL";
   string headers = "Content-Type: text/plain\r\n";
   char post[];
   StringToCharArray(body, post);
   char result[];
   string response_headers;

   int res = WebRequest("POST", url, headers, 10000, post, result, response_headers);

   if(res == -1)
      Print("WebRequest failed: ", GetLastError());
   else
      Print(CharArrayToString(result));
}
Send a SELL market order signal.
MQL4 example 3 — Close a ticket
void CloseTicketSignal()
{
   string url = "https://api.example.com/webhooks/your-bot-id";
   string body = "CLOSE, TICKET=12345678, COMMENT=MQL4_CLOSE";
   string headers = "Content-Type: text/plain\r\n";
   char post[];
   StringToCharArray(body, post);
   char result[];
   string response_headers;

   int res = WebRequest("POST", url, headers, 10000, post, result, response_headers);

   if(res != -1)
      Print("Close response: ", CharArrayToString(result));
}
Close one specific position by ticket.
MQL4 example 4 — GET request
void SendGetSignal()
{
   string url = "https://api.example.com/webhooks/your-bot-id?action=BUY&vol=0.10&sl=250&tp=500&tpsltype=PIPS&agent=external_api";
   string headers = "";
   char post[];
   char result[];
   string response_headers;

   int res = WebRequest("GET", url, headers, 10000, post, result, response_headers);

   if(res == -1)
      Print("GET failed: ", GetLastError());
   else
      Print("GET response: ", CharArrayToString(result));
}
Use GET query parameters instead of POST body.
MQL5 examples
Four WebRequest-based examples for MT5.
MQL5 example 1 — POST BUY
void SendBuySignal()
{
   string url = "https://api.example.com/webhooks/your-bot-id";
   string body = "BUY, VOL=0.10, SL=250, TP=500, TPSLType=PIPS, COMMENT=MQL5_BUY";
   string headers = "Content-Type: text/plain\r\n";
   char data[];
   StringToCharArray(body, data);
   char result[];
   string result_headers;

   int res = WebRequest("POST", url, headers, 10000, data, result, result_headers);

   if(res == -1)
      Print("WebRequest error: ", GetLastError());
   else
      Print(CharArrayToString(result));
}
Open a long position through webhook.
MQL5 example 2 — POST SELL
void SendSellSignal()
{
   string url = "https://api.example.com/webhooks/your-bot-id";
   string body = "SELL, VOL=0.10, SL=250, TP=500, TPSLType=PIPS, COMMENT=MQL5_SELL";
   string headers = "Content-Type: text/plain\r\n";
   char data[];
   StringToCharArray(body, data);
   char result[];
   string result_headers;

   int res = WebRequest("POST", url, headers, 10000, data, result, result_headers);

   if(res != -1)
      Print("Response: ", CharArrayToString(result));
}
Open a short position through webhook.
MQL5 example 3 — Close all
void SendCloseAllSignal()
{
   string url = "https://api.example.com/webhooks/your-bot-id";
   string body = "CLOSEALL, COMMENT=MQL5_CLOSE_ALL";
   string headers = "Content-Type: text/plain\r\n";
   char data[];
   StringToCharArray(body, data);
   char result[];
   string result_headers;

   int res = WebRequest("POST", url, headers, 10000, data, result, result_headers);

   if(res != -1)
      Print("CloseAll response: ", CharArrayToString(result));
}
Flatten all symbol exposure from MQL5.
MQL5 example 4 — Modify ticket
void SendModifySignal()
{
   string url = "https://api.example.com/webhooks/your-bot-id";
   string body = "MODIFY, TICKET=12345678, SL=20, TP=40, TPSLType=PIPS, COMMENT=MQL5_MODIFY";
   string headers = "Content-Type: text/plain\r\n";
   char data[];
   StringToCharArray(body, data);
   char result[];
   string result_headers;

   int res = WebRequest("POST", url, headers, 10000, data, result, result_headers);

   if(res != -1)
      Print("Modify response: ", CharArrayToString(result));
}
Modify SL/TP for a single existing ticket.
C++ examples
Four libcurl-based examples for GET, POST, CLOSE, and MODIFY.
C++ example 1 — POST BUY with libcurl
#include <curl/curl.h>
#include <iostream>
#include <string>

int main() {
    CURL* curl = curl_easy_init();
    if (!curl) return 1;

    std::string url = "https://api.example.com/webhooks/your-bot-id";
    std::string body = "BUY, VOL=0.10, SL=250, TP=500, TPSLType=PIPS, COMMENT=CPP_BUY";

    struct curl_slist* headers = nullptr;
    headers = curl_slist_append(headers, "Content-Type: text/plain");

    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    curl_easy_setopt(curl, CURLOPT_POST, 1L);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());

    CURLcode res = curl_easy_perform(curl);
    std::cout << "Result: " << res << std::endl;

    curl_slist_free_all(headers);
    curl_easy_cleanup(curl);
    return 0;
}
Simple POST request with text/plain body.
C++ example 2 — POST CLOSE
#include <curl/curl.h>
#include <string>

int main() {
    CURL* curl = curl_easy_init();
    if (!curl) return 1;

    std::string url = "https://api.example.com/webhooks/your-bot-id";
    std::string body = "CLOSE, TICKET=12345678, COMMENT=CPP_CLOSE";

    struct curl_slist* headers = nullptr;
    headers = curl_slist_append(headers, "Content-Type: text/plain");

    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    curl_easy_setopt(curl, CURLOPT_POST, 1L);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
    curl_easy_perform(curl);

    curl_slist_free_all(headers);
    curl_easy_cleanup(curl);
    return 0;
}
Close a specific trade by ticket.
C++ example 3 — GET request
#include <curl/curl.h>
#include <string>

int main() {
    CURL* curl = curl_easy_init();
    if (!curl) return 1;

    std::string url = "https://api.example.com/webhooks/your-bot-id?action=BUY&vol=0.10&sl=250&tp=500&tpsltype=PIPS&agent=external_api";

    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    curl_easy_perform(curl);
    curl_easy_cleanup(curl);

    return 0;
}
Call the webhook directly as GET with query params.
C++ example 4 — POST MODIFY
#include <curl/curl.h>
#include <string>

int main() {
    CURL* curl = curl_easy_init();
    if (!curl) return 1;

    std::string url = "https://api.example.com/webhooks/your-bot-id";
    std::string body = "MODIFY, TICKET=12345678, SL=20, TP=40, TPSLType=PIPS, COMMENT=CPP_MODIFY";

    struct curl_slist* headers = nullptr;
    headers = curl_slist_append(headers, "Content-Type: text/plain");

    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    curl_easy_setopt(curl, CURLOPT_POST, 1L);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
    curl_easy_perform(curl);

    curl_slist_free_all(headers);
    curl_easy_cleanup(curl);
    return 0;
}
Modify SL/TP for an existing ticket.

Troubleshooting

Request returns OK but no execution appears

Check symbol match, platform status, bot activation state, spread limits, deviation limits, and whether the channel/source is accepted.

GET works but POST does not

Make sure the POST body is sent as plain text and matches the builder syntax. Also verify the endpoint URL is correct and not truncated.

TradingView alert sends but order is wrong

Compare the alert message text with the builder output exactly. Small syntax mismatches can change parameter interpretation.

Close or modify action does nothing

Verify that TICKET is correct, the position still exists, and the bot/platform has permission to handle that request.

Security & best practices

Keep webhook URLs private and do not expose them publicly.
Always test on a safe bot before using live capital.
Prefer one symbol per bot to simplify operations and debugging.
Use descriptive bot names and comments so requests are traceable.
Keep one approved GET test and one approved POST test so you can verify your setup quickly whenever needed.
ConeyAlgo