Skip to main content

Send Custom Volume in TradingView Alert

Tutorial on how to send custom volume in TradingView alert to WunderTrading.

Written by Ben Ross

If you want to send a custom volume with each TradingView alert, you can enable this option in the bot settings. Once enabled, your TradingView alert details will update automatically.


Setup your volume in TradingView's PineScript

Insert the quantity (qty) parameter in the strategy.entry() function. In the example below, we set the quantity equal to 50. If you want your quantity to change dynamically, you can define a variable in your code that recalculates the amount you would like to send with each entry.

// Fixed amount example
strategy.entry("Long", strategy.long, qty = 50,alert_message = "Insert Enter Long Comment")

// Variable amount example
amount = x

// where "x" is your calculation how you would like to calculate the amount

strategy.entry("Long", strategy.long, qty = amount, alert_message = "Insert Enter Long Comment")

The qty argument in the function is optional. If you do not specify this argument, the strategy.entry() function will use the default_qty_type and default_qty_value parameters declared in the strategy() declaration statement to determine the quantity, and will pass the volume to the bot.

Next, copy the Enter Long or Enter Short comment from the bot’s menu and insert it into the alert_message argument. The action direction of the comment must match the position direction defined in the strategy.entry() function. If the position direction in strategy.entry() is not explicitly defined and is stored in a variable, then your code must also specify a dependency to automatically select the appropriate comment.

Setup the Alert

If your strategy is applied to the chart and you have made all the necessary settings in the strategy menu, then create an alert:


1) Select your Strategy(Condition)
2-3) Go to the Message tab and paste a small JSON object into the Message field in the alert window. In this object, specify the quantity type ("amountPerTradeType") you are using. To determine the correct type, carefully review the table provided below.

​​{

"code": "{{strategy.order.comment}}",

"amountPerTrade": "{{strategy.order.contracts}}",

"amountPerTradeType": "quote"

}

If you have only one trading pair in the bot, the available "amountPerTradeType" options are:

Parameter

Comment

"percents"

Interprets the amount you provide as a percentage of your exchange balance.

"base" (for spot and futures markets)
"contracts" (for futures market)

The quantity will be interpreted as the numbe of base coins or contracts. For example, in the BTC/USDT pair, the base currency is BTC, so you specify the amount of BTC you want to buy.

"quote"

Takes the amount you enter as the number of quote currency. In the BTC/USDT pair, the quote currency is USDT, so you need to enter the amount in dollars you want to spend.

If you have multiple trading pairs, then the "amountPerTradeType" options for you are:

Parameter

Comment

"percents"

Interprets the amount you provide as a percentage of your exchange balance

"$"

Treats the amount passed as a fixed value in USDT

4-5) Go to the Notifications section. Then copy the webhook URL from the bot’s settings menu and paste it into the Webhook URL field.
6) Click Save to complete the setup. That’s it — trading via the TradingView – WunderTrading – Exchange connection is now running.

It is extremely important to remember that once you create an alert, your strategy begins trading independently on a separate server and is no longer connected in any way to the strategy remaining on your chart. All the settings you configured in the strategy before creating the alert will be preserved in the trading strategy until you change the alert.

If you want to make changes to the settings of the trading strategy, you must apply those changes to the strategy on your chart and then create a new alert. The old alert will continue trading until you stop or delete it.

Did this answer your question?