# TradingView Webhooks

### Quick demo

{% embed url="<https://www.youtube.com/watch?v=FT7BZLSNkq8>" %}

### Stepwise guide:

1\. Create a Webhook

* Navigate to **Portfolio > Webhooks > New Webhook**.
* Provide a meaningful **name** and create the webhook.

<figure><img src="https://529851788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fas1ul3t7dYhXS2QfN6d4%2Fuploads%2FkTHaPLc40ND4YkxRaO97%2Fimage.png?alt=media&#x26;token=91540bb5-0d57-4b2c-8983-1382e0d175db" alt=""><figcaption></figcaption></figure>

2\. Authorize the Webhook

* Authorize the webhook to **open and close trades** on your account.

<figure><img src="https://529851788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fas1ul3t7dYhXS2QfN6d4%2Fuploads%2FBW6bapV0yFcXqEaZ9Oee%2Fimage.png?alt=media&#x26;token=05ea4268-41f5-4b59-b13a-86e62b4823c4" alt=""><figcaption></figcaption></figure>

3\. Copy the Webhook Body

* **Sign a message** to verify your identity and view the webhook body.
* **Copy and store** this content securely. Do **not** share it publicly.

<figure><img src="https://529851788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fas1ul3t7dYhXS2QfN6d4%2Fuploads%2FjHJokNaT1I0L7VYdKr6P%2Fimage.png?alt=media&#x26;token=e3683e22-05cd-44ff-a9fd-218856d024e2" alt=""><figcaption></figcaption></figure>

4\. Set Up a TradingView Strategy

* Choose a TradingView strategy that aligns with your trading style.
* **Verify** its performance through backtesting.

<figure><img src="https://529851788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fas1ul3t7dYhXS2QfN6d4%2Fuploads%2FJ9TJjgrs1wPqrorGnSDF%2Fimage.png?alt=media&#x26;token=8b0c9a36-37ed-4350-8008-de89a6a0a2e1" alt=""><figcaption></figcaption></figure>

5\. Configure Trade Size

* Choose settings > Properties
* **Note:** **1 TradingView quantity = 0.001 asset in polynomial**

<figure><img src="https://529851788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fas1ul3t7dYhXS2QfN6d4%2Fuploads%2FD3A15ECeHkbAWwwGNxs3%2Fimage.png?alt=media&#x26;token=11be6b62-3fb9-4906-a75c-cdaccf2deb30" alt=""><figcaption></figcaption></figure>

<figure><img src="https://529851788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fas1ul3t7dYhXS2QfN6d4%2Fuploads%2FHNeqvEVcNIl4CULrD9g9%2Fimage.png?alt=media&#x26;token=cf6bef5a-6fc5-4f3b-a911-8695cfc5485c" alt=""><figcaption></figcaption></figure>

6\. Create Alerts in TradingView

* Create an alert linked to your strategy.
* Copy and paste the **webhook URL and body** when setting up the alert.

<figure><img src="https://529851788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fas1ul3t7dYhXS2QfN6d4%2Fuploads%2FLi239FUA6t5sEOKDkFlv%2Fimage.png?alt=media&#x26;token=15dae548-4cd8-4031-aeb4-eead14b590b3" alt=""><figcaption></figcaption></figure>

<figure><img src="https://529851788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fas1ul3t7dYhXS2QfN6d4%2Fuploads%2FUHaq7dzEFRil1HgMhHll%2Fimage.png?alt=media&#x26;token=fc4c1b15-a8ae-4fb5-b978-15370aa2833e" alt=""><figcaption></figcaption></figure>

![](https://529851788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fas1ul3t7dYhXS2QfN6d4%2Fuploads%2FqqoiucYqh89AnscKwUaE%2Fimage.png?alt=media\&token=44bc0ed1-a9a8-4e7e-ae5a-b9d90a2a1ead)\
7\. Sync Open Positions

* When backtesting, TradingView may already assume an open position.
* To stay in sync, **open the same position size in Polynomial** before the webhook triggers.

### FAQ

**1. How should I align open positions in Polynomial with my strategy?**\
You must manually establish the same position size in Polynomial that your backtest assumes. This ensures that alerts correctly reverse or modify positions rather than opening duplicate trades.

**2. Is there a sizing requirement for contracts?**\
Yes. In Polynomial, **1 TradingView Contract = 0.001 asset**. Ensure that you configure your trade size in TradingView accordingly.

**3. Are there any security steps I should follow?**\
Yes. You are required to sign a message to verify your identity before accessing the webhook body. The webhook body should be copied, stored securely, and never shared publicly, as it is protected to prevent unauthorized access.

**4. Can I use multiple strategies with different webhooks?**\
Yes. Polynomial supports multiple webhooks, each of which can be linked to a different TradingView strategy. Alternatively, you may also use the same webhook to manage trades from multiple strategies if desired.\
\
&#x35;**. Why is my trade size incorrect?**\
The most common reason is that after an alert is created, changes to the strategy settings do not automatically update the alert. To correct this, you must delete the existing alert, update the strategy settings, and then create a new alert.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.polynomial.fi/explanations/tradingview-webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
