how to send some data to specific url when an alert triggered in pine script?

Viewed 35

I am familiar with the webhook in pine script. webhook's problem is that does not allowed to send data with post curl.

how can I send some data (multiple float values) to a url when a statement in my indicator is happens ?

(I want to made a robot that get a api from trading view)

thanks in advance

1 Answers

You can definitely send data with the webhook.

When you define an Alert, you set the Alert name and Message fields. The Alert name is just a string (for you, to differentiate among alerts), but the Message field can contain built-in variables you can define in your script, runtime. On the Alert creation window there is a text "You can use special placeholders such as {{close}}..." and a question mark, which leads to the documentation.

Ie.: you can set a variable (say, al_mes) to a certain value (which can control your app on the other end of the webhook) and when you define strategy.entry() it will accept an alert message field, where you should put that al_mes variable:

strategy.entry(id='Above Open', direction=strategy.long, alert_message=al_mes, comment = 'To the Moon')

That alert message variable will be put into the internal variable alert_message which you can place into the alert creation window's Message field as {{strategy.order.alert_message}}.

When the Alert is triggered, the webhook will be queried with a HTTP POST request and the contents of {{strategy.order.alert_message}} which is equivalent to al_mes will be put into the request as POST DATA.

This is how 3Commas.io bots work with Tradingview Custom Signal.

Related