Tradingview Binance Automated Trading
Binance Trading Bot
Setup guide – How to do automated trading ETHUSDT on Binance exchange (USD-M Futures)
Updated 22.04.2023! This guide explains how to setup and use Traderelay v.410 and later versions.
This process might seem complicated, but its actually quite simple.
The complication comes from the fact that there are 3 different platforms that has to be setup: Tradingview -> Traderelay -> Exchange (Binance)
But after they are setup, you have Trading Bot trading 24/7 on Binance exchange. Then you can start tweaking your strategies.
Setup steps
1. SETUP TRADINGVIEW.COM
1. Go to website www.tradingview.com and login. (Dont have account yet? Open account here. (included is our referrer code)
2. After login. Go to chart screen in tradingview. Choose ETHUSDT as symbol.
3. Press ‘Pine Editor’-tab below the chart and copy paste our example Study code from below. Press Save. Press Add to Chart. -> now you should see startegy added to you ETHUSDT chart.
Example strategy with alerts
This code written with Pinescript v.4.
Just copy-paste it to Tradingview.com -> chart window -> Pine Editor -> Save -> Add to chart.
//STRATEGY CODE START
//@version=4
study("Traderelay 4 Example Study", overlay=true)
sma1 = sma(close, 14)
sma2 = sma(close, 55)
plot(sma1)
plot(sma2)
longCondition = crossover(sma1, sma2)
shortCondition = crossunder(sma1, sma2)
//ENTRIES
qt=1
//entry long
plotshape(longCondition, style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny, title='longCondition', text='longCondition', textcolor=color.new(color.white, 0))
alertcondition(longCondition, title='longCondition', message='action:LONG symbol:{{ticker}} qt:1 id:xxxx')
//entry short
plotshape(shortCondition, style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny, title='shortCondition', text='shortCondition', textcolor=color.new(color.white, 0))
alertcondition(shortCondition, title='shortCondition', message='action:SHORT symbol:{{ticker}} qt:1 id:xxxx')
//STRATEGY CODE ENDS
2. SETUP ALERTS IN TRADINGVIEW
Now that your study is running succesfully in tradingview.com chart window. Create alerts for it. Alerts will send LONG or SHORT command to Traderelay and onwards to real exchanges.
Create alert
1. Go to “Alerts”-section, its on upper right navigation. Create new alert with following settings.
2. Condition: choose your study from dropdown (“Traderelay 4 Example Study”).
3. Choose “Once per bar close”.
4. Fill checkbox “webhook”. Insert webhook url: http://srv3.traderelay.net
4. Copy paste your personal webhook id to message (Change xxxx to your personal webhook id) (webhook id you can get from Traderelay software)
5. Press “Create”. Thats it! Now your study will send alert message to traderelay software everytime alert is triggered.
Commands (use these in Tradingview alerts)
SHORT -> example command: action:SHORT symbol:ETHUSDT qt:1 id:xxxx (if you have long position, this command will close it and sell short.)
CLOSE -> example command: action:CLOSE symbol:ETHUSDT id:xxxx (use this to close position, stoploss, etc.)
CLOSELONGHALF -> example command: action:CLOSELONGHALF symbol:ETHUSDT id:xxxx (close half of your long position) (Updated 22.04.2023!)
CLOSESHORTHALF -> example command: action:CLOSESHORTHALF symbol:ETHUSDT id:xxxx (close half of your long position) (Updated 22.04.2023!)
*CLOSELONGHALF or CLOSESHORTHALF can be used multiple times, until if there is only one token or stock left, then it will close position.
Under development (Work but not fully tested)
LONGLIMIT -> example command: action: LONGLIMIT symbol:XRPUSDT qt:15 limitprice:0.4689 id:xxxxx (Limit order to buy long XRPUSDT for price of 0.4689)*Cancels automatically all other currently active orders that might be active.
*If you have opposite position to your new limit order, its added to your orders qt.
*Decimal precision is 4.
SHORTLIMIT -> example command: action: SHORTLIMIT symbol:XRPUSDT qt:15 limitprice:0.4689 id:xxxxx (Limit order to sell short XRPUSDT for price of 0.4689)
3. SETUP TRADERELAY SOFTWARE
-Install TradeRelay software on your computer
1. Set Binance API keys
-Login with your email and password
-Go to Settings tab and fill in: your api keys for Binance.
-Save settings
2. Setup instruments
You have to have atleast one instrument on instrument list before you start Traderelay software.
Instrument can be paused, but there needs to be atleast one instrument so software can loop the list.
-On main page of Traderelay software, add instrument symbol: ETHUSDT
-Choose ETHUSDT from the list and click sectype Binance -> this sets the exchange to Binance
3. Start traderelay
-Press START and TradeRelay begins to loop through your instruments -> checking received alerts from Tradingview -> relaying orders to exchanges
(in this case Binance -> USD-M Futures ).
-PLEASE TEST IT FIRST WITH PAPERTRADING OR SMALL MONEY!!
4. SETUP BINANCE CRYPTO EXCHANGE
-You will need to open Binance account.
You will need API keys for SPOT exchange or Futures exchange.
-In binance you can trade normally in SPOT-exchange, but it supports only LONG. (Shorting wont work here.)
-If your strategy trades LONG and SHORT -> enable USD-M Futures exchange here: Binance Futures.
-Move some money to your SPOT or FUTURES account and start trading.
5. SETUP COMPLETE
After you have succesfully completed above 4 step you should be able to run trading bot 24/7 in Binance exchange.
Checklist:
-Tradingview.com is sending alerts (with your webhook id) %
-Traderelay is looping and waiting alerts (incoming alerts have your webhook id + some command) %
-Binance account has money and API keys have been inserted to Traderelay settings %
FIREWALL SETTINGS (OPTIONAL)
Usually there is no need to change firewall setting on your windows.
But if you have trouble and alerts are not forwarded to Binance -> go to your computers firewall settings and allow application “Traderelay software” in and out.
This should allow Traderelay to send and receive API commands to Binance.