Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Sending a webhook AND and a message in Pinescript v5

Writer Andrew Henderson

enter image description hereIt appears that through the alert() function you can code a message to be sent, but what about the webhook?

I would like to use capitalise.ai, and they require to set in the alert both a webhook () and a message, for example {"alertId": "b2f0d9f2-a848-48e4-8218-70350b24xxxx"} which will trigger a specific action, for example to buy or to sell.

Fact is, if I set in the UI an alert for a strategy I have created in Tradingview, there will be only one alert for all the possible events, and therefore only one message, but then how can I tell Capitalise.ai if the alert is for selling or buying?

I could do something like

if enterLong alert("message 1))
else if enterShort alert("message2"))

But then where do I put the webhook?

Thank you

2

4 Answers

Your code must include something like this :

alert(jsondata, alert.freq_once_per_bar)

with jsondata a string in the json format.
Then your jsondata (your message) will be sent to your webhook.

To create the weebhook, look in the Alert Menu from your Tradingview Chart :
Choose the nae of your strategy in the Condition (Bybit Bot in the screenshot),
and create a 'Open-ended alert' alert :
enter image description here

Then go on the notification menu to give the url for the webhook :
enter image description here

2

You need different messages for different orders.

Check out this tutorial.

1

I do something like this with a discord alert. Create your message in the script and not in the message box on the alert fly out.

I use this in a library

export GetDiscordJson(string userName, string avatar_url, string content, string title, string url, string description, string _fields, string _footer, string _authObject, string clr) => //parameters with _ lead are already formatted for the json end object _username = jsonKeyValuePair("username", userName) _avatarUrl = jsonKeyValuePair("avatar_url", avatar_url) _content = jsonKeyValuePair("content", content) _title = jsonKeyValuePair("title", title) // title = ticker _url = jsonKeyValuePair("url", url) _description = jsonKeyValuePair("description", description) _color = jsonKeyValuePair("color", clr) _embeds = str.format("\"embeds\":[{0}\n{1},\n{2},\n{3},\n{4},\n{5},\n{6},\n{7}\n{8}]", "{", _authObject, _title, _url, _description, _color, _fields, _footer, "}") str.format("{0}\n{1},\n{2},\n{3},\n{4}\n{5}", "{",_username, _avatarUrl, _content, _embeds, "}")

Then in the indicator call it on each kind of alert

if enterLong content = w.GetDiscordJson(_botName, _avatarURL, contMessage, syminfo.ticker, _titleURL, chartTimeframe, _fields, _footerObject, _authObject, _color ) alert(content, alert.freq_once_per_bar) 

Simply put the webhook json string you get from capitalise into the alert(Capitalise-string,alert-frequency) command in your script. and then you can based on condition in your script decide which capitalise string to send. The alarm setup can only be done once with just the capitalise webhook URL, and leaving the message box empty. Hope that’s understandable 😀

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.