TradingView Integration for Bot trading and Copy trading (investment)
Overview
Target audience
Pre-requisites
-
Connected exchange
- Enable copy trading. Follow this link to learn how.
Step 1: Create an investment Bot
- Bot type selection: choose the type of bot you want to create, which in this case would be Invest since the signals will be for your own investment or copy trading.
-
Compose your portfolio: define the set of symbols that your bot should monitor.
Select the exchange, the currency (BTC, USDT, or BUSD), and the account type (Spot or Futures). Drag and add the symbols you want the bot to monitor into the portfolio area.
Anny supports multiple symbols in one bot, but since TradingView supports only one symbol per alert, you will need to create separate alerts for each symbol. -
Automation settings: specify the setup for signal parameters, particularly outlining the criteria for automated entry and exit.
-
Entry (Auto Invest)
- Entry mode (market or advanced DCA)
- Investment allocation: can be configured in either BTC or USDT. This allocation represents the maximum amount that can be allocated across active signals from a bot or signal group.
- Position size: the investment amount allocated to a position, either by fixed risk or fixed investment, relative to the total allocated capital. To learn more, click here.
- Risk limit: to further manage your risk exposure, you can define a maximum risk limit for your allocated capital in active trades.
- Entry method: automatically creates an entry order at the moment a new signal is published or sends a message requesting authorization to enter the signal.
- For Futures signals define also the margin, position side and leverage.
- Exit (Auto Stop, Trailing Take Profit, and Take Profit): set Auto Stop parameters (Loss percent and Stop-loss limit margin), Trailing Take Profit parameters (Trigger by target profit, stop order position, and Take profit), and Take Profit parameters (Goal type, goal, and order type).
- Learn more about each automation by accessing the links below:
Auto invest
Auto stop
Trailing take profit
Take profit
-
- Launch: Review your data, define the recurrency, name it and your bot will be ready to be launched.
Step 2: Link the Bot with your TradingView alert using webhooks
-
From the Dashboard tab, select the Bots section from the menu on the left, and on the card click on Strategy: TradingView alert in order to open the webhook and template information.
- In your TradingView alert settings, select the Webhook URL option and copy the parameter from Anny, then paste it into your TradingView alert. Similarly, for the Message field, copy the parameter from Anny and paste it into your TradingView alert.
Python can also be used but we do not provide support, you need to contact TradingView support. - Anny will create the SIGNAL with the parameters defined in TradingView's message.
Templates:
- Complete strategy for SPOT account: you can set the Investment, Take Profit (up to 5 targets are supported, use 'targetProfit1', 'targetProfit2', etc), and Stop-loss recommendations.
Example:
{"symbol":"BTCUSDT","invest":"10%","targetProfit":"4%","stopLoss":"2%"} - Complete strategy for FUTURES account: for Futures accounts, additional parameters like account type, margin type, leverage, and position side can be added.
Example:
{"symbol":"BTCUSDT","invest":"10%","targetProfit":"4%","stopLoss":"2%","account":"FUTURES","marginType":"ISOLATED","leverage":"1","side":"long"} - Entry and exit strategy: it is possible to send entry and exit signals through TradingView, and all risk management (stop loss, take profit, etc.) would be done "internally" by the trader.
To do an Entry and Exit signal, the message must contain a "Signal id" field in order to close the correct signal when sending an exit signal. The field typology is alphanumeric 20 characters.
Example:
Entry: {"symbol":"BTCUSDT","invest":"10%","signalId":"john123"}
Exit: {"symbol":"BTCUSDT","type":"close","signalId":"john123"}
It is possible to send an exit alert without the "Signal id" field, this will close all open positions for that symbol.
Configuration overrides:
The TradingView message field is optional if you've already configured distribution settings in the prior step (distribution settings).
The message comes with predefined settings, but these values can be customized to align with your strategy.
You have the option to input specific values to override the default settings for a specific signal.
If you prefer not to make any alterations, unselect any chosen template option and simply copy and paste the message as it appears in TradingView.
For instance, let's say you've set up a bot with three symbols (XRP, ADA, and SOL). For XRP and ADA, there's no need to modify your distribution strategy, but for SOL, you'd like to have a different stop loss for the signal. When pasting the message into TradingView, make sure to include the stop loss values to replace the ones entered in the previous step.
For example, in the distribution step, you specified a 2% stop, but when entering the message in TradingView, you entered a 3% stop. Consequently, the signal will be generated with a 3% stop.
- Position size: can be defined either by fixed investment or by fixed risk.
Examples:
Fixed investment:
{"symbol":"{{ticker}}","invest":"10%"}
Fixed risk:
{"symbol":"{{ticker}}","risk":"10%"} - Fixed values: fixed values can also be used instead of percentages. In practice the fields are the same, just insert the fixed price without the "%".
In long positions, the prices must be placed in ascending order.
In short positions, the prices must be placed in descending order.
Example:
{"symbol":"BTCUSDT","invest":"10%", "entryPriceMin": "19500", "entryPriceMax": "20500","targetProfit":"21500","stopLoss":"19264"} - Market entry mode: makes a market entry when the price is within the range.
The range can be defined by price or percentage.
Examples:
Rage (price): {"symbol":"{{ticker}}","entryPriceMin": "19500", "entryPriceMax": "20500"
Range (percentage)
Short: {"symbol":"{{ticker}}","entryPriceMin": "-0.4%", "entryPriceMax": "0%"
Long: {"symbol":"{{ticker}}","entryPriceMin": "0%", "entryPriceMax": "0.4%" - DCA entry mode: for DCA entry mode to be activated, at least 2 entries are required. That is, the entry1Percent and entry2Percent fields must be present and greater than zero.
When the entry1Price field is omitted, the current market price of the asset is assumed.
The price fields (entry*Price) must be in descending order for long signals and ascending order for short signals.
The entry*Price fields can be defined either by price or percentage.
Define the percentage (of the total investment) for each entry. The sum needs to be 100%.
Example:
DCA (price)
{"symbol":"{{ticker}}","entry2Price":"19500","entry3Price":"20500","entry1Percent":"20%","entry2Percent":"30%","entry3Percent":"50%"}
DCA (percentage)
{"symbol":"{{ticker}}","entry2Price":"10%","entry3Price":"20%","entry1Percent":"20%","entry2Percent":"30%","entry3Percent":"50%"}
Calculation method for each entry: Position size * the defined percentage.
Calculation example:
Investment allocation: 5000 USDT
Position size: 10%
Position amount: 500 USDT (5000 * 10%)
Entry 1 (20%): 100 USDT ( 500 * 20%)
Entry 2 (30%): 150 USDT (500 * 30%)
Entry 3 (50%): 250 USDT (500 *50%)
Rules regarding the STOP:
-
Omitting the STOP is only permissible when the signal pertains to INVESTMENT (signals generated by the user themselves).
-
A STOP must be included in the signal when it is intended for DISTRIBUTION to a group.
Common issues
- A signal was triggered but got rejected.
Please double-check the message field parameters for accuracy and consistency, as even an extra character can affect the distribution. Keep a close eye on Anny's notifications; she'll alert you if something isn't quite right. - The TradingView alert went off, but Anny didn't make the signal. Ensure that the symbol associated with the alert has been added to your Anny bot.
- A signal was accepted but the investment wasn't executed.
There could be various reasons for not entering a position, such as API issues, insufficient balance, or auto-invest being turned off, among others. To promptly resolve any obstacles to successful trade entries, regularly monitor your positions and stay attentive to Anny's notifications.
How do I check why I didn't enter a position?
Additional resources
-
Generate take profit signals using the TradingView Webhook. Click here to learn how.
-
Monetize your signals, by creating a group and adding a subscription or a profit sharing plan. Click here to learn more.
-
Backtest your signals and check if they are correctly firing.
In order to test if the Bot is firing and distributing the signals accordingly you can test it allocating a very small amount so you can receive the signal but NOT enter it.