You can now send TradingView alerts to BitMex thanks to the Tradingview to Anywhere tool. The bot uses human-like commands that can be combined with TradingView’s dynamic alert messages .
How to Automate TradingView Script to BitMex
-
Head over to [TradingView To BitMex]https://tradingview.to/bitmex) and scroll to the step-by-step guide to get started.
-
Head over to the BitMex account and navigate to the API keys page to create new API keys.
-
Give your API key a name, and enter our IP address 34.89.98.97. Do not forget to append /32 at the end.
If you do not want to restrict your keys to a single IP address, leave this field empty.
-
For key permissions, select order and create API key.
-
submit your API key on the TradingView To BitMex website. and select next to submit the secret key.
-
If you are using a testnet account, tick the test box in the next step.
-
Click next and customize your webhhook name should you love to, select finish and proceed to set up alerts on TradingView as explained below:
Automating TradingView Strategy to BitMex
For a strategy with a long and short command only, use {{strategy.order.action}} which returns the string “buy” or “sell” for the executed order.
For a strategy with long, short, and exit/flat commands use {{strategy.market_position}} which returns the current position of the strategy in string form: “long”, “flat”, or “short”.
Specify the symbol name and quantity as outline in the Automation Guideline
Please note the following:
-
Quantity Q can be passed as either a percentage of your balance or as the contract size.
-
The Minimum contract size for USD pairs is 100.
-
The Minimum contract size for USDT pairs is 1000.
-
The correct symbol name is obtained from the address bar.
For Example;
-
A strategy with long and short commands only.
Close XBTUSDT
{{strategy.order.action}} XBTUSDT Q=1000
This command closes any XBTUSDT open position before executing the strategy command with the minimum contract size of 1000 equivalent to 0.001BTC.
Close XBTUSD
{{strategy.order.action}} XBTUSD Q=100
The close command has been applied on the first line to make sure any open positions are closed before opening new ones.
-
A strategy with long, short, and flat commands,
{{strategy.market_position}} XBTUSDT Q=2000
or
{{strategy.market_position}} XBTUSD Q=200
In this case, there is no close command applied on the first line since the strategy is able to generate an exit command before the next position.
Automating a TradingView Indicator to BitMex
To automate a TradingView indicator to Bitmex, you need to set two alerts. One for the long option and one for the short option.
- Create an alert from your indicator and choose the long or short option.
- Select once per bar close or once per bar.
- Paste your Webhook URL into the Webhook URL field.
- Paste the applicable buy/sell command in the message field.
For example;
-
For a Long condition, the applicable command will be;
Close XBTUSDT
Buy XBTUSDT Q=1000
or
Close XBTUSD
Buy XBTCUSD Q=100 -
For a Sell condition, the applicable command will be;
Close XBTUSDT
Sell XBTUSDT Q=1000
or
Close XBTUSD
Sell XBTCUSD Q=100
The close command is again applied on the first line to make sure that the previous position is closed before opening a new one.
TradingView Automation has never been this simple!