How to Automate TradingView Alerts to BitMex: Step-by-Step Guide

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

  1. Head over to [TradingView To BitMex] and scroll to the step-by-step guide to get started.

  2. Head over to the BitMex account and navigate to the API keys page to create new API keys.

  3. Give your API key a name, and enter our IP address 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.

  4. For key permissions, select order and create API key.

  5. submit your API key on the TradingView To BitMex website. and select next to submit the secret key.

  6. If you are using a testnet account, tick the test box in the next step.

  7. 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;

  1. 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.

  1. A strategy with long, short, and flat commands,

    {{strategy.market_position}} XBTUSDT Q=2000


    {{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.

  1. Create an alert from your indicator and choose the long or short option.
  2. Select once per bar close or once per bar.
  3. Paste your Webhook URL into the Webhook URL field.
  4. 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

    Close XBTUSD
    Buy XBTCUSD Q=100

  • For a Sell condition, the applicable command will be;
    Close XBTUSDT
    Sell XBTUSDT Q=1000

    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!