Triggers - Webhook (Trading View, etc.)

Modified on Fri, 11 Apr at 8:36 PM

Webhook triggers allow a TAT trade entry to be triggered by an external source, such as Trading View or any other service that can POST to a URL. When the POST is received by the TAT web server, it is immediately relayed to your TAT installation for execution.


To set up a Webhook trigger, on the Triggers page, create a new trigger. Enter the settings you would like to use for your trade and select "Webhook" for the Entry Trigger type and click Save Trigger.



Then click Edit on your newly created trigger. This will show you the custom URL to communicate with your TAT installation and the data to POST. You will use this information in the 3rd party tool creating the webhook request. The URL and POST data are specific to both your TAT account, the computer it is running on and the specific Trigger.



NOTE: It is possible to trigger more than one trade with a single POST. To set that up, after creating both triggers in TAT, open up each and take note of the number listed inside the brackets after TriggerID. More than one numeric TriggerID can be included in a single POST. The TriggerIDs would be listed in a comma separated list inside the brackets when setting up your alert in Trading View.  For example: "TriggerID": [1,3]


POST Values

Token: An alphanumeric string to identify your account. This is provided in your TAT install.


Timestamp: {{time}} needs to be in the following format: 2024-02-12T06:25:00Z and should be the current UTC time when the request was sent. (TradingView will do this automatically if you use the {{time}} token in your alert.)

Instance: An alphanumeric string to identify your TAT installation. This will differ if you run TAT on multiple computers or with multiple brokers. This is provided in your TAT install.


TriggerID: Integer that identifies the Trigger to be executed when the webhook is received. This is generated by your TAT install after saving the Trigger.


CloseTriggerID: Integer that identifies the trades to be closed opened by this TriggerID the webhook is received. This is generated by your TAT install after saving the Trigger. (More information below)


Responses


A valid submission will return a 200 HTTP response code. 


An invalid submission not matching the format above will return a 415 HTTP error response code.


Closing Trades via Webhook (Early Exit)


It is also possible to close a trade via a webhook call. The trade(s) to close must have been opened originally by a trigger, not a scheduled trade. The setup for the closing webhook is the same as opening a trade, except in the POST data, you will provide a "CloseTriggerID" instead of "TriggerID".


IMPORTANT: Please treat closing trades via webhook as an optional "early exit" for the trade. It is important to also have stops set for the trade that you would be ok having fill. The webhook triggered closing trade is not guaranteed and might not execute if there were to be technical problems with the service that should be triggering it, with the TAT web server receiving the webhook POST, or with the connection between the TAT server and your TAT software.



Testing Webhook Connection


When you create a Webhook trigger, the webhook connection to the TAT server will be enabled. The connection starts automatically when TAT is connected and will automatically reconnect as necessary if it is disconnected. 



On the Settings page, there is a button to test the webhook connection. After pressing the button, you will check the Logs tab. If everything is connected properly, you will see a line similar to this:





Trading View Alert Webhooks


Trading View is one of the most widely used charting tools in use today. There are hundreds of indicators that can be added to their charts, or the possibilities are endless with their Pinescript coding language to build your own. Trading View allows you to create Alerts based on pricing data or an indicator on a chart. When your Alert triggers in Trading View, it can be configured to make a webhook POST request to TAT.


When creating an alert in Trading View, copy the Webhook POST Data from TAT and set it as the Message field when saving the alert. (Be sure there is nothing else in the Message field).



Then for the Notifications, Check Webhook URL and enter the URL provided in TAT:



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article