Discussing the article: "Foundation Models in Trading: Time Series Forecasting with Google's TimesFM 2.5 in MetaTrader 5"

 

Check out the new article: Foundation Models in Trading: Time Series Forecasting with Google's TimesFM 2.5 in MetaTrader 5.

Time series forecasting in trading has evolved from traditional statistical models (like ARIMA) to deep learning approaches, but both require heavy tuning and training. Inspired by advances in NLP, Google’s TimesFM introduces a pretrained “foundation model” for time series that can perform strong forecasts even without task-specific training. For traders, this is powerful because it can be efficiently fine-tuned on their own data using lightweight methods like LoRA, reducing overfitting while adapting to changing market conditions.

In the natural language processing domain, we have witnessed a paradigm shift: large foundation models, pretrained on vast corpora and then adapted to specific tasks, have displaced the "train from scratch" workflow. The question naturally arises: can this transfer learning revolution work for time series?

Google Research answered this affirmatively with TimesFM (Time Series Foundation Model), introduced in the paper "A decoder-only foundation model for time-series forecasting" and accepted at ICML 2024. TimesFM is a 200-million-parameter, decoder-only transformer pretrained on 100 billion real-world time points. Despite being much smaller than contemporary LLMs, it achieves strong zero-shot performance across domains and granularities. In many cases, it matches or outperforms supervised models trained on the target datasets.

This is particularly useful for algorithmic trading because it can be fine-tuned on proprietary financial data. Using PEFT with LoRA adapters, we can specialize TimesFM for specific instruments while keeping trainable parameters below 100K. This helps reduce overfitting on non-stationary market data.

In this article, we build a complete end-to-end pipeline that:

  1. Exports OHLCV data from MetaTrader 5 for 14 instruments (forex pairs, indices, commodities)
  2. Constructs a rich covariate dataset incorporating moon phases, economic calendar events, market sessions, and technical features
  3. Fine-tunes TimesFM 2.5 with LoRA adapters on this financial data
  4. Generates probabilistic forecasts with quantile estimates (10th, 50th, 90th percentiles)
  5. Exports the forecasts back into MetaTrader 5 as CSV files
  6. Visualizes the predictions directly on the chart via a custom MQL5 indicator with confidence bands


    Author: Seyedsoroush Abtahiforooshani