Discussing the article: "Python + LLM API + MetaTrader 5: Real-World Experience Building an Autonomous Trading Bot"

 

Check out the new article: Python + LLM API + MetaTrader 5: Real-World Experience Building an Autonomous Trading Bot.

The article describes the development of an MVP prototype for an autonomous trading bot for MetaTrader 5 that uses large language models (LLMs) via the OpenRouter API to analyze the market and make trading decisions. A Python script retrieves historical OHLCV data, sends it to an LLM for technical analysis based on support/resistance levels and Price Action patterns, and then automatically places orders with specified stop loss and take profit levels.

Most traders have no idea that AI is capable of:

  • finding levels,
  • identifying candlestick patterns,
  • recognizing trends,
  • comparing previous sections of the chart,
  • drawing well-reasoned conclusions,
  • analyzing multiple timeframes,
  • correcting its own mistakes when optimizing the prompt.

This is neither an indicator nor an algorithm but an intelligent add-on that can be adapted to your personal trading system.

And most importantly, it does not need to be taught how to program. It understands ordinary human language.


Author: Aleh Daikou

 
From the title, I thought it would cover training a local model, but once again it’s all about relying on other people’s ready-made models and servers, which aren’t optimised for time series at all. All in all, the word ‘autonomous’ (i.e. self-sufficient) in the title is superfluous.
 
In my view, modern models have a comprehensive ‘worldview’, know a whole host of strategies, understand time series and do not require further training. They correctly identify support and resistance levels, as well as highs and lows; this is evident from the LLM’s ‘reasoning’. Via the API, you can select powerful models without being tied to local hardware.
Stanislav Korotky #:
Once again, we’re relying on other people’s ready-made models and servers

Where can I read about “ready-made models and servers”? Please share. I’ve actually come across solutions involving the fine-tuning of local LLMs.


Stanislav Korotky #:
the word “autonomous”
‘Autonomous’ in this context means not requiring trader intervention. The bot analyses the situation, makes a decision and opens an order all by itself.
 
Oleg Doykov #:
In my view, modern models have a comprehensive ‘worldview’, know a whole host of strategies, understand time series and do not require further training. They correctly identify support and resistance levels, as well as highs and lows; this is evident from the LLM’s ‘reasoning’. Via the API, you can select powerful models without being tied to local hardware.

Where can I read about ‘pre-trained models and servers’? Please do share. I’ve actually come across solutions involving the fine-tuning of local LLMs.

I’ve just mentioned that this article uses pre-trained models and servers.

In the discussion of another article (where the model is downloaded and run locally), in which you also participated, I provided a link to a comparative study of general language models (which were not trained on time series) and those specifically trained on time series. The results do not favour large language models.

From my experience with general-purpose LLMs, it appears that they are very prone to making up facts in the factual part of their responses, particularly when it comes to numerical figures.

Быстрая интеграция большой языковой модели и MetaTrader 5 (Часть I): Создаем модель
Быстрая интеграция большой языковой модели и MetaTrader 5 (Часть I): Создаем модель
  • 2025.11.12
  • www.mql5.com
Статья исследует революционную интеграцию больших языковых моделей (LLM) с торговой платформой MetaTrader 5, где AI не просто прогнозирует цены, а принимает автономные торговые решения, анализируя контекст рынка подобно опытному трейдеру. Автор раскрывает фундаментальное отличие LLM от классических моделей машинного обучения вроде CatBoost — способность к метапознанию и саморефлексии, что позволяет системе учиться на собственных ошибках и улучшать стратегию.
 
Stanislav Korotky #:

I’ve just mentioned that this article uses ready-made models and servers.

In the discussion of another article (where the model is downloaded and run locally), in which you also took part, I provided a link to a comparative study of general language models (which were not trained on time series) and those specifically trained on time series. The results do not favour large language models.

From my experience with general-purpose LLMs, it appears that they are very prone to making up facts in the factual part of their responses, particularly when it comes to numerical figures.

Hello. My article on the backtesting of the local Ollama model using 1,000 trades will be published shortly. Surprisingly, the results on synthetic, artificial samples of ideal trades are several times better than those on actual real-world trades.

There will also be a third part – replacing the built-in model with my own language transformer architecture, fine-tuned for finance.

Overall, they’re trading quite well; I’m tackling hallucinations by lowering the temperature, and I’m also developing a version with a new MIT feature for language models – SEAL – which creates a self-training pipeline, and further training takes place directly via instructions in the model’s queries; the context length is a bit of a hindrance, but on the other hand, compressed network experience can be stored within the context – by extracting it from the model’s own responses. The LoRa adapter can also be enabled and fine-tuned specifically on financial data. Again, the need for high-end hardware for large models is a major drawback...

Grok 4.1 is also working really well in the version with 1 million context tokens; that’s an excellent window size, and you can load loads of trades and data into it. The issue comes down to the cost of the tokens—it’s not a cheap business.)
 
Stanislav Korotky #:
In the discussion of another article (where the model is downloaded and run locally), in which you also participated, I provided a link to a comparative study of general language models (which were not trained on time series) and those trained specifically on time series. The results do not favour large language models.

Stanislav, thank you for the article; I’ve found it, and it’s very useful. I must have missed it somehow – I suppose I was too lazy to translate it.


This article explores the problem of classical time series forecasting. Time series represent a specific, narrow sector for solving trading problems.

The authors conclude that, for classical time series forecasting, LLMs currently offer almost no benefit in terms of quality, whilst significantly increasing computational costs; the same level of performance (or better) can be achieved using much simpler architectures without a language model.

However, the authors also believe that LLMs should not be used for ‘bare-bones’ time series forecasting, but rather in situations where there is textual context alongside the time series and natural language reasoning is required.
Multimodal ‘time series + text’ tasks: where the model must take into account news, event descriptions, social context, textual instructions, etc. (time series reasoning, social understanding, financial reasoning).

Right on the first page:


time series reasoning

Translation:

In fact, recent work points to a multitude of interesting and promising ways in which language and time series interact, such as time series reasoning [25, 7, 45, 42, 37], social understanding [6] and financial reasoning [36, 20].

This is exactly what I’m talking about: multimodality.

My hypothesis is that a modern LLM is a self-sufficient ‘organism’ that ‘knows everything’, including trading.
The task is to narrow the language model’s ‘worldview’ to solve a specific problem. To train a trader.
Yes, it does seem like ‘using a sledgehammer to crack a nut’.

Stanislav Korotky #:
From my experience with general-purpose LLMs, it seems they are very prone to stretching the truth in the factual parts of their answers, particularly when it comes to numerical figures.

Oh yes. That’s certainly food for thought. Choosing the right model, formulating a strategy in the prompt and setting clear boundaries is no easy task. Models from the leaderboards usually provide more accurate answers. They analyse situations sensibly and make informed decisions.

I agree with this comment:

Forum on trading, automated trading systems and testing trading strategies

Discussion of the article “Rapid Integration of a Large Language Model and MetaTrader 5 (Part I): Creating a Model”

Edgar Akhmadeev, 13 November 2025 00:33

I started working on this topic not long ago. I’m writing the OpenAI API in pure MQL5. And the server for the model is llama.cpp.

You need to give the model instructions that are as mathematically precise as possible and demand clear answers, without any fluff. Lower the temperature to the minimum (0–0.2) so that it doesn’t start fantasising. Select the largest local models that the system can handle (on my 12 Gb VRAM – up to 15B, and with a slight slowdown – up to 30B). Test them and select the best one (and there are plenty to choose from). Whilst you’re doing this, model development continues, and small, smart models are emerging. You can then fine-tune the model (LoRA). If, God forbid, there’s a hint that the project might be profitable, you can switch to large, paid online models. Or at least upgrade your computer to 2 GPUs with 24 Gb and plenty of memory.

There’s work galore. We’ll see. We’ll try working with the models, taking their charming quirks into account.



Обсуждение статьи "Быстрая интеграция большой языковой модели и MetaTrader 5 (Часть I): Создаем модель"
Обсуждение статьи "Быстрая интеграция большой языковой модели и MetaTrader 5 (Часть I): Создаем модель"
  • 2025.11.12
  • www.mql5.com
Опубликована статья Быстрая интеграция большой языковой модели и MetaTrader 5 (Часть I): Создаем модель : Автор: Yevgeniy Koshtenko...
 
Yevgeniy Koshtenko #:
Hello. My article on the back-testing of the local Ollama model using 1,000 trades will be published shortly. Surprisingly, the results on synthetic, artificial samples of ideal trades are several times better than those on actual real-world trades.

There will also be a third part – replacing the built-in model with our own language transformer architecture, refined for finance.

Overall, they trade quite well; I’m tackling hallucinations by lowering the temperature, and I’m also working on a version with a new MIT feature for language models – SEAL – which creates a self-training pipeline, and further training takes place directly via instructions in the model’s queries; the context length is a bit of a hindrance, but on the other hand, the context can store the network’s compressed experience – by extracting it from its own responses. The LoRa adapter can also be enabled and fine-tuned specifically on financial data. Again, the need for high-spec hardware for large models is a major drawback...

Grok 4.1 also works brilliantly in the version with 1 million context tokens; that’s an excellent window size, and you can load loads of trades and data into it. The issue comes down to the cost of the tokens – it’s not a cheap business)

An interesting study. I’m really looking forward to the rest of the season )).

A dataset with synthetic trades – that’s something new.

Tokens vs Hardware.

[Deleted]  
Would anyone be able to write a good back-tester for the LLM APIs? As it stands, it’s not really clear what we’re discussing :)
 
Maxim Dmitrievsky #:
Would anyone be willing to write a good back-tester for the LLM APIs? As it stands, it’s not really clear what we’re discussing :)
We’ll get round to the tester sooner or later, but it’ll run almost in real time. On my hardware, the analysis takes 12–13 seconds, at a rate of 19.25 tps.
 

Related: 5 LLMs traded autonomously for 8 months using market data and news (the model training approach has not been disclosed).

Autonomous trading of 5 LLMs over a period of 8 months