This article will elaborate on a few specific commands that will help you avoid common errors when configuring your custom Binance strategies automation.
Parameters
Exchange [e=]
e=binance -Spot and Margin markets
e=binancefutures -USDT Futures
e=binancefuturestestnet -USDT Futures Testnet
e=binancedelivery -COIN Futures
e=binancedeliverytestnet -COIN Futures Testnet
e=binanceus
Symbol [s=]
e=binance s=bnbbtc
e=binancefutures s=btcusdt
e=binancedelivery s=btcusd_perp or s=btcusd_201225
Spot markets typically match Tradingview and not the URL on Binance itself.
USDT Futures markets can be copied and pasted from the Binance URL for that market.
COIN Futures markets are similar to their URL on Binance, their API just cuts "perpetual" down to "perp". For the markets that expire, we need to construct their symbol code.
Use the code from the website and add the last two digits of the current year in front of them.
market = btcusd_quarter
code = 1225
s=btcusd_yearCode
Example:
e=binancedelivery s=btcusd_201225 b=long q=1% t=market d=1
The below script is an example of converting the Tradingview symbol to a ticker that Binance requires via their API by removing the `PERP` and replacing it with nothing (empty quotes).
//@version=4
strategy("Symbols", overlay=true, margin_long=100, margin_short=100)
symbol = str.replace_all(syminfo.ticker, "PERP", "")
if close > 0
alert(message=symbol)
If you're still unsure of the correct symbol, you can navigate to the syntax builder within your extension, and select the relevant market. If the exchange provides all symbols, they will appear in the symbols dropdown.
Book [b=]
e=binance s=bnbbtc b=buy SPOT
e=binance s=bnbbtc b=sell SPOT
e=binance s=bnbbtc b=long MARGIN
e=binance s=bnbbtc b=short MARGIN
The is no different between buy and long or sell and short on futures and delivery markets.
Advanced Orders
Open with a stop-limit order
Spot, Futures and Delivery all function the same here
- We added tp/sl to be used with c=position, however, it can also be used to open new stop-limit and stop-market trades. This however means that Autoview will think it is "closing" a position because so the opposite of your b= will be placed. To maintain backwards compatibility within the extension, this is something that worked by default and could not be corrected.
e=binance s=BNBBTC b=buy sl=-10% d=1
e=binance s=BNBBTC b=sell tp=10% t=market d=1
Take Profit / Stop-Loss / Trailing-Stop
current price + value or fixed price
tp= or ftp=
sl= or fsl=
ts= or fts=
Spot does not have positions, so these only work as closes on futures and delivery. You can use a new open like above to mimick these on spot.
You can add the stops to an existing position using c=position.
You can use the positions average instead of the current price by adding ps=position.
e=binancefuturestestnet s=btcusdt b=long c=position ps=position tp=10% d=1
e=binancefuturestestnet s=btcusdt b=long c=position ps=position sl=-10% d=1
e=binancefuturestestnet s=btcusdt b=long c=position ps=position ts=-1% d=1
With these values being calcualted from the current price, you need to reverse the positive and negative values when closing a short.
e=binancefuturestestnet s=btcusdt b=short c=position ps=position tp=-10% d=1
e=binancefuturestestnet s=btcusdt b=short c=position ps=position sl=10% d=1
e=binancefuturestestnet s=btcusdt b=short c=position ps=position ts=1% d=1
One cancels the other
oco=1
This will place both, your take-profit and stop-loss in one command. When one order fills, the other will be cancelled.
e=binance s=bnbbtc b=sell q=1 sl=-50% px=-50% p=50% oco=1
px= sets the trigger price for the stop-loss.
sl= sets the price of the stop-loss once triggered.
p= sets the price of your take-profit.
You can use sl= and tp= interchangeably here.
fixed-price [fp=] can be used in place of price[p=]
Disclaimer! - OCO orders are NOT supported through Binancefutures.
Wallet Transfers
e=binance y=futures q=100 w=usdt
e= define the API you want to transfer FROM
y= define the wallet you are transferring to
q= defines the amount
w= defines the currency
Comments
0 comments
Article is closed for comments.