By default, BitMEX candles are created using a combination of historic trades and orderbook data. For candles with traded volumes, OHLC candles are created using the first, highest, lowest and last traded price in the period respectively. For candles in which there was no traded volumes, candles are created using the median of last traded price, the best bid and the best ask price at the end of the window.
There is an option to create candles using traded prices only. To do this, deselect the Use Mid-Market Charts under TradingView charts settings: