【问题标题】:Sending a webhook AND and a message in Pinescript v5Sending a webhook AND and a message in Pinescript v5
【发布时间】:2022-12-01 20:28:05
【问题描述】:

It appears that through thealert()function you can code a message to be sent, but what about the webhook?

I would like to usecapitalise.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

【问题讨论】:

  • did you manage to resolve this? I am looking for a similar solution via pinescript.
  • hi, any news about how to solve this? I'm also looking something similar. thx

标签: webhooks pine-script pinescript-v5


【解决方案1】:

You need different messages for different orders.

Check out this tutorial.

【讨论】:

  • 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
【解决方案2】:

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}
{1},
{2},
{3},
{4},
{5},
{6},
{7}
{8}]", "{", _authObject, _title, _url, _description, _color, _fields, _footer, "}")
    str.format("{0}
{1},
{2},
{3},
{4}
{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) 

【讨论】:

    猜你喜欢
    • 2021-11-28
    • 2022-12-02
    • 2022-11-20
    • 2022-11-09
    • 2022-12-02
    • 2022-12-19
    • 2022-12-02
    • 2022-12-02
    • 2022-08-17
    相关资源
    最近更新 更多