3

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 (https://tvwebhook.capitalise.ai) 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

4 Answers4

2

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

G.Lebret
  • 2,826
  • 2
  • 16
  • 27
  • How would this work? there is no place to set the webhook in this function, even if the message is in the json format expected by the receving app? how does it get posted to the endpoint? – TheOriginOf3 Jan 05 '23 at 18:56
  • @TheOriginOf3 I updated my answer for the webhook part. – G.Lebret Jan 05 '23 at 20:21
0

You need different messages for different orders.

Check out this tutorial.

vitruvius
  • 15,740
  • 3
  • 16
  • 26
  • Sorry, but this does not help me at all :) I have stated quite clearly that I cannot do it through the UI, I need to do it through pinescript code. These tutorials are about creating an alert triggering on specific conditions, and that is clear, I know how to do it. But I have already my own strategy that triggers its own alerts, and those alerts cannot be replicated by creating alerts through the UI based on conditions. The alerts must triggered directly by the strategy – Giovanni Dominoni Feb 20 '22 at 12:11
0

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) 
-1

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

Jonny
  • 1