Mercor
Search…
Automate your TradingView strategy
The script below is a template that you can add to your TradingView strategy to fully automate it with just 1 alert. Please find a tutorial below explaining how you can incorporate the script below into your strategy!
1
//Alerts
2
var enter_long_msg = "Enter Long"
3
var exit_long_msg = "Exit Long"
4
​
5
order_type_buy = "buy"
6
order_type_sell = "sell"
7
​
8
​
9
//Edit this Region
10
algorithm_id = "" // Given on creation of algorithm on Mercor
11
secret = "" // Given on creation of algorithm on Mercor
12
slippage = "0.0002" // 0.002 which corresponds to 0.2%
13
relative_amount = "0.1" // 0-1, 1 = 100%
14
// Remember to add the webhook - https://app.mercor.finance/API_reroute
15
//End Edit Region
16
​
17
if secret != "" and algorithm_id != ""
18
enter_long_msg := '{"order_type":"' + order_type_buy + '","algorithm_id":"' + algorithm_id + '","secret":"' + secret + '","slippage":"' + slippage + '","relative_amount":"' + relative_amount + '"}'
19
exit_long_msg := '{"order_type":"' + order_type_sell + '","algorithm_id":"' + algorithm_id + '","secret":"' + secret + '","slippage":"' + slippage + '","relative_amount":"' + relative_amount + '"}'
20
​
21
​
Copied!
In order to trigger all alerts corresponding to your script use the following command:
{{strategy.order.alert_message}}
​
​
Copy link