Financial Market Analysis (Double-Tower Transformer) A developer built a Double-Tower Gated Transformer Network (GTN) to generate profitable trading signals from high-frequency EUR/USD forex data. The system uses a custom cost matrix and weighted cross-entropy loss to combat class imbalance, and optimizes for raw profitability under real-world MetaTrader 5 constraints. Despite overfitting on a single batch, the model underfitted when scaled to one epoch with maximum parameters on an A100 GPU. A predictive machine learning system explicitly designed to generate profitable trading signals from high-frequency 1-minute EUR/USD forex data. The flagship focus of this repository is a custom Double-Tower Gated Transformer Network GTN built to predict Take Profit / Stop Loss TP/SL strikes. The data pipeline processes 1-minute OHLC bars to map out realistic TP/SL bounds over a 24-hour lookahead rather than using fixed time horizons. The core model, the Gated Transformer Network GTN , utilizes a dual-tower architecture that separates feature interactions from temporal sequences. It replaces traditional sinusoidal encodings with learned time embeddings to capture market regime shifts and session overlaps London, NY, Tokyo . To combat severe class imbalance the model's tendency to constantly predict "keep/hold" , the network optimizes against a custom cost matrix and weighted cross-entropy loss. Pasted image 20260710145647.png Instead of optimizing for standard classification accuracy, the pipeline tackles raw profitability. The intent is for models to learn the structural mechanics of price action, balancing Risk/Reward ratios e.g., 1:2 against real-world MetaTrader 5 execution constraints enforcing next-candle open entries and proper UTF-16-LE signal formatting . buy precision + sell precision /2 - 0.25 |buy precision - sell precision| find out why despite everything we underfitted? I did manage to overfit on a single batch of data; however, based on the scaling laws paper, I tried to do 1 epoch with proportionate maximum parameters that I can efficiently fit into the 80GB VRAM of an A100 GPU or 2 40GB VRAM of A100 depending of availability. reference paper: https://arxiv.org/pdf/2103.14438 https://arxiv.org/pdf/2103.14438 Gated Transformer Networks for Multivariate Time Series Classification