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++.
TradingView alerts, scripts, external tools, and manual tests can all target the same generated webhook endpoint.
Keeping one symbol per bot makes execution, debugging, and risk isolation much easier.
The same action syntax works across GET, POST, TradingView alerts, ReqBin, Python, C++, MQL4, and MQL5.
Spread filters, drawdown, DCA, time windows, stop loss, trailing, and deviation control belong in the same operating flow.
You can use direct copy-paste examples instead of relying only on generic explanations.
This page includes ready examples for Pine Script, Python, MQL4, MQL5, and C++.
Before you connect live TradingView alerts, validate your bot from the browser and from a POST tool.
Quick Start
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.
Parameters reference
The destination trading account/platform that will receive the execution.
Friendly bot name used for identification and management.
Controls which execution sources are accepted.
Optional label describing where the signal came from.
Your bot should target one exact symbol.
Enable averaging logic for the bot.
Defines averaging direction behavior.
Maximum open trades allowed for the cycle.
Maximum distance allowed between incoming signal price and broker price.
Maximum spread allowed before execution is blocked.
Enable TP handling for the bot.
Enable SL handling for the bot.
Used as Stop Loss normally, or DCA step when DCA is enabled.
Take Profit value in points.
Enable trailing logic.
Trailing step distance.
Distance used by trailing stop logic.
Maximum allowed drawdown percentage.
Bot start time in HH:mm format.
Bot stop time in HH:mm format.
Optional rule to flatten positions before weekend.
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.
Supported payload style
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.
https://api.coneyalgo.xyz/webhooks/fe37f641-67a9-4733-9d4a-c343b4a24bd7?action=BUY&agent=external_api{
"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"
}
}https://api.coneyalgo.xyz/webhooks/fe37f641-67a9-4733-9d4a-c343b4a24bd7buy,agent=external_api{
"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.
//@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)//@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)//@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)//@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)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)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)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)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)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));
}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));
}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));
}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));
}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));
}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));
}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));
}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));
}#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;
}#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;
}#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;
}#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;
}Troubleshooting
Check symbol match, platform status, bot activation state, spread limits, deviation limits, and whether the channel/source is accepted.
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.
Compare the alert message text with the builder output exactly. Small syntax mismatches can change parameter interpretation.
Verify that TICKET is correct, the position still exists, and the bot/platform has permission to handle that request.