Mercor
Search
K

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!
//Alerts
var enter_long_msg = "Enter Long"
var exit_long_msg = "Exit Long"
order_type_buy = "buy"
order_type_sell = "sell"
//Edit this Region
algorithm_id = "" // Given on creation of algorithm on Mercor
secret = "" // Given on creation of algorithm on Mercor
slippage = "0.0002" // 0.002 which corresponds to 0.2%
relative_amount = "0.1" // 0-1, 1 = 100%
// Remember to add the webhook - https://app.mercor.finance/API_reroute
//End Edit Region
if secret != "" and algorithm_id != ""
enter_long_msg := '{"order_type":"' + order_type_buy + '","algorithm_id":"' + algorithm_id + '","secret":"' + secret + '","slippage":"' + slippage + '","relative_amount":"' + relative_amount + '"}'
exit_long_msg := '{"order_type":"' + order_type_sell + '","algorithm_id":"' + algorithm_id + '","secret":"' + secret + '","slippage":"' + slippage + '","relative_amount":"' + relative_amount + '"}'
In order to trigger all alerts corresponding to your script use the following command:
{{strategy.order.alert_message}}