Auto Trade Bot Integration
Last updated
Last updated
Since most bots use market orders for entering and exiting during sudden volatile moves, slippage can occur between actual entry/exit and the signal.
An auto trade bot isn't a set-and-forget strategy; you still need to monitor and adjust settings over time to ensure good performance.
Here will introduce 2 of the most popular crypto trading bots (TTA and 3Commas). You can integrate with other bots too, you just need to paste the corresponding code to the algo settings.
After pasting all codes, you will need to create an alert. Alert name can be anything easy to recognize and replace the message with the following code:
This code will be automatically replaced by the codes you pasted in the bot integration setting. For example, if the algo generates a long signal, the "Long" code will be passed to the message.
Change the notifications to Webhook URL and paste the bot's Webhook.
TTA is an affordable, easy-to-use third-party bot for automated trading. You need to connect your exchanges to their official site. We'll use ByBit BTCUSDT as an example:
*Each exchange has different codes; please refer to TTA official site for more information.
Long code: Long BTCUSDT Q=10%
Short code: Short BTCUSDT Q=10%
Using Long/Short to represent the order. BTCUSDT is the trading pair. Q is the position size, 10% means 10% of the total account equity (some exchanges allow sub-accounts); you can also use a fixed value, like Q=0.01 for a 0.01 BTC position.
TP1 code: Close BTCUSDT Q=50%
TP2 code: Close BTCUSDT Q=100% 或 Close BTCUSDT
We use Q to represent the percentage of the position. Q=50% closes 50% of the position at TP1, and Q=100% or no percentage specified closes 100% of the position at TP2.
If SL gets hit before TP1, both codes trigger, and the entire position closes.
Close All Longs code: Close BTCUSDT T=Long
Close All Shorts code: Close BTCUSDT T=Short
When using dynamic take profit mode, since there are no fixed TP1/TP2, use Close All Longs/Shorts to close all positions at once.
Even if not using dynamic take profit mode, it's recommended to paste both Close All Longs/Shorts codes, especially when using SignalPro -Scalping, because some SL modes are dynamic (e.g., soft stop loss).
After pasting all codes, paste the Webhook from your TTA account to TradingView notification.
3Commas is a more advanced bot, offering greater complexity and additional features. First, connect your crypto exchanges to 3Commas; we'll use ByBit BTCUSDT as an example.
3Commas uses the same Webhook URL for all bots. As long as you're using 3Commas, paste the following Webhook to TradingView notification:
Due to 3Commas' limitations, Long/Short/TP1/TP2 bots must be created separately. You'll need 4 bots for each trading pair: Long TP1, Long TP2, Short TP1, and Short TP2. We'll use Long TP1 as an example:
First, create a DCA Bot, the name can be anything easy to recognize: BTC 15 Long TP1
Select your exchange and trading pair.
Strategy: Choose Long or Short
Base order size: Since you're creating separate TP1 and TP2 bots, divide your desired total position size between them. For example, if you want a total position size of 4000 USDT, set a 2000 USDT base order size for each bot.
Remember that the base order size represents the position value, so if your order size is 1000 USDT and you're using 10x leverage, you're actually only entering with 100 USDT.
Start order type: It's recommended to use limit order, you can save fees and can avoid slippages.
Leverage type: Choose between isolated margin and cross margin.
Leverage custom value: Adjust the leverage you want to use.
Deal start condition: Select Trading View custom signal
Since we're using Algo for TP/SL, there's no need to set them on 3Commas. Ensure the take profit on 3Commas isn't too low to avoid closing positions prematurely.
Safety orders: We don't want any of that.
Leave other settings as default and click "Start" at the top right corner.
Now repeat the steps above until BTC 15 Long TP1, BTC 15 Long TP2, BTC 15 Short TP1, and BTC 15 Short TP2 are all created. You can use the "Copy" function to speed things up.
After all 4 bots are created, click on each of them.
Scroll down and find "Message for deal start signal" and "Message to close order at Market Price". Don't need to change anything.
Long code: [{ "message_type": "bot", "bot_id": 10857490, "email_token": "faf47631-xxxx-xxxx-xxxx-xxxxxxxxxx", "delay_seconds": 0}, { "message_type": "bot", "bot_id": 10857572, "email_token": "faf47631-xxxx-xxxx-xxxx-xxxxxxxxxx", "delay_seconds": 0}]
Short code: [{ "message_type": "bot", "bot_id": 10857633, "email_token": "faf47631-xxxx-xxxx-xxxx-xxxxxxxxxx", "delay_seconds": 0}, { "message_type": "bot", "bot_id": 10857642, "email_token": "faf47631-xxxx-xxxx-xxxx-xxxxxxxxxx", "delay_seconds": 0}]
For the Long code, we'll need "Message for deal start signal" of both BTC 15 Long TP1 and BTC 15 Long TP2, same for the Short code, we'll use "Message for deal start signal" of both BTC 15 Short TP1 and BTC 15 Short TP2.
You can use brackets to combine 2 codes and separate each one with a comma: [code 1, code 2]
TP1: [{ "action": "close_at_market_price", "message_type": "bot", "bot_id": 10857490, "email_token": "faf47631-xxxx-xxxx-xxxx-xxxxxxxxxx", "delay_seconds": 0}, { "action": "close_at_market_price", "message_type": "bot", "bot_id": 10857633, "email_token": "faf47631-xxxx-xxxx-xxxx-xxxxxxxxxx", "delay_seconds": 0}]
TP2: [{ "action": "close_at_market_price", "message_type": "bot", "bot_id": 10857572, "email_token": "faf47631-xxxx-xxxx-xxxx-xxxxxxxxxx"", "delay_seconds": 0}, { "action": "close_at_market_price", "message_type": "bot", "bot_id": 10857642, "email_token": "faf47631-xxxx-xxxx-xxxx-xxxxxxxxxx"", "delay_seconds": 0}]
For TP1, we'll use "Message to close order at Market Price" of both BTC 15 Long TP1 and BTC 15 Short TP1. TP2 will use "Message to close order at Market Price" of both BTC 15 Long TP2 and BTC 15 Short TP2.
Close All Longs code: [{ "action": "close_at_market_price", "message_type": "bot", "bot_id": 10857490, "email_token": "faf47631-xxxx-xxxx-xxxx-xxxxxxxxxx", "delay_seconds": 0}, { "action": "close_at_market_price", "message_type": "bot", "bot_id": 10857572, "email_token": "faf47631-xxxx-xxxx-xxxx-xxxxxxxxxx", "delay_seconds": 0}]
Close All Shorts code: [{ "action": "close_at_market_price", "message_type": "bot", "bot_id": 10857633, "email_token": "faf47631-xxxx-xxxx-xxxx-xxxxxxxxxx", "delay_seconds": 0}, { "action": "close_at_market_price", "message_type": "bot", "bot_id": 10857642, "email_token": "faf47631-xxxx-xxxx-xxxx-xxxxxxxxxx", "delay_seconds": 0}]
Close All Longs will use "Message to close order at Market Price" of BTC 15 Long TP1 and BTC 15 Long TP2. Close All Shorts will use "Message to close order at Market Price" of BTC 15 Short TP1 and BTC 15 Short TP2.
Even without dynamic take profit mode, it's advisable to paste both Close All Longs/Shorts codes, particularly when using SignalPro - Scalping, as some SL modes are dynamic, such as soft stop loss.