Discussing the article: "Foundation Models for Trading (Part I): Porting Kronos to Native MQL5"

 

Check out the new article: Foundation Models for Trading (Part I): Porting Kronos to Native MQL5.

Kronos is a pretrained transformer that models OHLCV bars the way a language model predicts words. We reimplement its tokenizer/encoder and transformer block in native MQL5, export weights to flat .bin files, and remove Python from runtime entirely. Part 1 delivers preprocessing and BSQ tokenization plus a bit-for-bit verification harness against PyTorch, so you can run the encoder inside MetaTrader 5 with confidence.

Kronos treats a candlestick chart the way a language model treats text. A sentence is a sequence of tokens drawn from a fixed vocabulary. Kronos turns a sequence of candles into a sequence of discrete tokens drawn from its own learned vocabulary, then predicts the next token the way a language model predicts the next word. To generate a forecast, it samples tokens one at a time and converts them back into candles.

That design splits the model into two cooperating networks. The first is the tokenizer, an autoencoder that learns to compress a bar of six features into a pair of small integer tokens and to reconstruct the bar from those tokens. The second is the predictor, a decoder-only transformer that, given the token history, predicts the next pair of tokens. The two halves are trained separately and used together: encode the context window into tokens, let the predictor extend the token sequence, decode the new tokens back into candles.

The specific weights we port are Kronos-Tokenizer-base and Kronos-small, the smallest released pair. Even "small" here means a 512-dimensional, 8-layer transformer, so the forward pass is real work. Everything in this part concerns the tokenizer's encoder and the shared transformer machinery; the predictor and the decoder arrive in Part 2.

Kronos pipeline overview: context window to tokens to forecast candles

Author: Muhammad Minhas Qamar