TradingView alert integration

Connecting the TradingView platform to the Psyll webhook system enables full trading automation. This article provides a comprehensive guide, from setup to best practices, to help you optimize your trading.

Webhook

Automate trades and trigger actions by connecting external alerts through fully customizable webhooks.

Integrating TradingView alerts with the Psyll webhook system enables the automatic transmission of trading signals from the TradingView platform to a webhook-enabled system. This allows users to execute trades on an exchange in real-time without the need for manual input. The solution boosts precision and speed, facilitates full automation of trading strategies, and reduces the risk of order execution delays. This document details the webhook configuration process, provides practical examples (including using placeholders for dynamic strategy adjustments), and offers tips and best practices for effective trade automation.

A unique webhook URL

Every webhook in the Psyll system has a unique URL in the following format:

https://psyll.com/env/webhook/{WEBHOOK-ID}

This URL should be entered into the Webhook URL field in the TradingView alert settings, within the Notifications section. The unique ID {WEBHOOK-ID} is generated when a new webhook is created in the webhook management panel in the Psyll system.

It is important to copy it precisely, as the slightest error in the address can prevent signals from being sent correctly.

Practical tips:

  • Double-check for any spaces at the beginning or end of the URL.
  • Always use the latest, active webhook ID, especially if you are generating new test sessions.

The unique URL allows the Psyll system to accurately identify the alert source and assign the signal to the correct webhook.

TradingView alerts integration

Integrating a webhook with the TradingView platform's alerts allows for flexible customization of alerts to various trading strategies and dynamic market conditions. Alerts can be configured based on manually defined conditions, such as crossing a specific price level, a price increase, a price decrease, an upward or downward movement, a change in volume, or in conjunction with strategies written in Pine Script, which allows for more advanced trading automation. This flexibility supports both simple, manual alerts and complex algorithmic strategies, adapting to the user's individual needs.

To configure a TradingView alert, follow these steps:

Go to the Alerts section in TradingView and click the + icon to create a new alert.

In the Condition field, select the condition that triggers the alert, such as a price level breach, a volume change, an upward or downward move, or the name of a Pine Script strategy.

In the Notifications section, paste the unique webhook URL obtained from the Psyll panel into the Webhook URL field.

In the Message field, enter the message content in JSON format, which will define the webhook's action in response to the signal.

Message - Transmitting instructions

The Message field in TradingView alerts is used to transmit detailed instructions to the Psyll system's webhook. Messages in JSON format allow for full control over automated trading actions on a selected exchange, including specifying the action, quantity, and instrument symbol. Each JSON must contain a unique webhook code {WEBHOOK-CODE} that identifies the alert within the Psyll system, as well as the appropriate parameters, such as:

  • action: specifies the type of operation (e.g., SET, BUY, SELL).
  • quantity: specifies the amount of the base asset to sell or buy.
  • symbol: specifies the financial instrument (e.g., BTCUSDC).

Below are examples of typical operations that can be automated using JSON messages, along with an explanation of their function.

SET - Setting an exact portfolio balance

If a user wants the portfolio balance to be exactly a specific amount of an asset  0.1 BTC after a signal occurs, the Psyll system will automatically adjust the portfolio state:

  • If the balance is greater than the target 0.1 BTC, the system will sell the excess to equalize the portfolio state.
  • If the balance is less than the target, the system will purchase the missing amount.

Example JSON message for this operation:

{
    "code": "{WEBHOOK-CODE}",
    "action": "SET",
    "quantity": "0.1",
    "symbol": "BTCUSDC"
}

BUY - Buying a specific amount after a signal

In a scenario where a user wants to buy a specific amount of cryptocurrency after a signal occurs, the BUY action is used. For example, to buy 0.01 BTC with USDC, the JSON message would look like this:

{
   "code": "{WEBHOOK-CODE}",
   "action": "BUY",
   "quantity": "0.01",
   "symbol": "BTCUSDC"
}

This operation is useful in strategies based on buy signals, enabling an immediate reaction to positive market conditions.

SELL - Selling a specific amount after a signal

Similarly, to sell a specific amount of cryptocurrency after a signal occurs, the SELL action is used. An example JSON message for selling 0.01 BTC for USDC:

{
   "code": "{WEBHOOK-CODE}",
   "action": "SELL",
   "quantity": "0.01",
   "symbol": "BTCUSDC"
}

This action supports hedging strategies, allowing for quick profit-taking or loss minimization.

Messages placeholders

The TradingView platform lets you use placeholders in the "Message" field to dynamically insert data from charts or Pine Script strategies directly into a JSON message. This allows users to automatically transmit information like the instrument symbol, position size, action type, or the current state of a strategy without manual entry. Placeholders fully support strategy automation, enabling bots to adapt to real-time market data and signals from the algorithm.

For instance, if a user wants their portfolio balance to align with a Pine Script strategy's current position and have the instrument symbol automatically pulled from the chart, the JSON message would look like this:

{
    "code": "{WEBHOOK-CODE}",
    "action": "BUY",
    "quantity": "{{strategy.position_size}}",
    "symbol": "{{ticker}"
}

Here, the {{strategy.position_size}} placeholder dynamically fetches the position size from the Pine Script strategy, while the symbol can be replaced with {{ticker}} to make the webhook work for any instrument pair. This setup enables complete trading automation, precisely matching the portfolio balance to strategy signals. Each order generated by the strategy is instantly reflected, preventing delays and manual errors.

Placeholders can also be used for the action type itself, such as {{strategy.order.action}}, which automatically retrieves whether the strategy recommends a buy or sell. When combined with {{strategy.order.contracts}} (the number of units) and {{ticker}} (the instrument symbol), the system sends the exact orders triggered by the strategy, ensuring full synchronization with the algorithm's dynamic decisions. An example JSON message is shown below:

{
    "code": "4RLP9KZeMzPppeKK",
    "action": "{{strategy.order.action}}",
    "quantity": "{{strategy.order.contracts}}",
    "symbol": "{{ticker}}"
}

This setup allows trading bots to automatically mirror every Pine Script signal, enabling immediate reactions to changing market conditions, full automation of the trading process, and optimal use of portfolio funds. Placeholders eliminate the need for manual order changes and make it easy to scale strategies across different instruments without reconfiguring the webhook.

Best practices and tips

When setting up the integration, it is crucial to copy the webhook code {WEBHOOK-CODE} and ID {WEBHOOK-ID} exactly from the management panel to avoid communication errors. Before going live, it's a good idea to test the alert on a demo account to verify the configuration. The symbol in the JSON message (e.g., BTCUSDC) must match the format used by your integrated exchange. Regularly checking the trading log in the management panel helps confirm that orders are being executed as intended. Store your unique webhook code and ID securely to prevent unauthorized access.

Summary

Integrating TradingView alerts with a webhook is a powerful tool for automating trading strategies with high precision and flexibility. By correctly configuring the URL, JSON code, and placeholders, users can efficiently execute buy, sell, or balance adjustment orders based on market conditions or Pine Script signals. This integration with the management panel gives you full control, allowing for quick reactions to market changes and optimizing trading activity—a major benefit for users seeking complete automation in their private trading bots.