The phenomenon of related trading, in which organized communities engage in coordinated trading activities, poses a significant threat to the financial markets. Such activities can facilitate financial fraud, such as insider trading, price control, and market manipulation. Therefore, the detection of related trading is crucial for regulators to take actions to maintain market fairness and reduce market risk. The key challenge in detecting related trading is to measure the relevance of the trading behaviors of traders. Trade data is often represented as time series data, and traditional methods for analyzing such data typically focus on designing complex handcrafted features to measure the similarity of these time series. However, these methods are often incapable of capturing the complexity and variability of trading behaviors, which can be confusing and misleading. In this paper, we address this limitation by introducing a Hierarchical Transformer-based Siamese Network (HTSN) for related trading detection. The HTSN learns the correlation of the trade data from two accounts in an end-to-end manner, and is able to better capture trading information by splitting the data into different scales and stacking multiple Transformer encoders to extract features hierarchically. The experimental results on real-world data from China's futures market, indicate that the proposed HTSN model substantially outperforms previous approaches in detecting related trading.