Structure rules. Learning how to structure programmes, exploring possibilities, errors, solutions, etc. - page 9

 
hrenfx:

Don't think I'm being clever, but take another look at this architecture of writing a combat TC. There is no feedback.

There are virtual positions and there is a real trading environment which is fitted to the virtuality.

In that case, it doesn't even matter if netting is in the platform or another accounting system.

I think it is a very interesting structure, especially for high-speed strategies which cannot be checked on the regular tester.

Only, it's not quite clear about the "smart synchronizer". Probably they mean an adaptive copyer of trade orders whose task, if I understand correctly, is to adjust virtual profitability / profitability of the strategy and the current state of the market - liquidity, execution speed, etc...

In general, it would be good to have such a tester and synchronizer not monolithically built in the Expert Advisor, but as a separate external module.
In this case, any Expert Advisor or several ones may be connected to it and even selectively use the most appropriate signals.

I wonder if this is realistic using only MQL...

 

This is a separate module in terms of logic.

For example, the Signals service is a separate module, not related to the TS in any way:

It simply translates virtual source positions (they are virtual for you) into your trading environment.

Curiously (not optimally), of course, but it translates.

Торговые сигналы
Торговые сигналы
  • www.mql5.com
Торговые Сигналы для MetaTrader: копирование сделок, мониторинг счета, автоматическое исполнение сигналов и социальный трейдинг
 
hrenfx:

This is a separate module in terms of logic.

For example, the Signals service is a separate module, not related to the TS in any way:

It simply translates virtual source positions (they are virtual for you) into your trading environment.

Curiously (not optimally), of course, but it translates.

It turns out that there is a Google translator that translates crookedly but will do if you don't need to understand it, but if you need to understand it precisely - learn the language).

I would be satisfied with an intermediate option - a personal, high-quality translator (module), when the translation is good and there is no need to write code in each EA.

 

Understanding how to structure a programme comes with experience. Everyone here has different experiences, and so the order and rules of structuring will be unique. Moreover, these rules will change over time - that is, what seemed an ideal structure a couple of years ago, today may not withstand even the lightest criticism.

The structure of programs in MQL is a separate song, because it is in essence a DSL, controlled by events from the terminal (although huge steps have been made to bring it closer to general purpose languages). Imho, for the description of trading strategies the best way is a state machine, and there already were some articles about it here. Actually the structure degenerates into a big case with a lot of encludes for realization of each case.

Abstracting away from trading tasks, I usually allocate a core part, which knows nothing about the specifics of interaction with the user. Its purpose is to provide a way to fill itself with data, solve the problem based on the received data and output the result. The core may physically consist of several files, but all of them must be logically connected and provide outside only methods of receiving data and methods of returning data and nothing else. The simplest analogy is a meat grinder.

The second thing I think is important is localising the parts to be changed (or the parts that could potentially be changed) and separating them into a separate abstraction. With this approach, we can seamlessly switch between different implementations of the mechanism (for example, by switching the position opening mechanism, we can virtualize trading). Different implementations are conveniently stored in a separate folder with a generic name.

The project structure will resemble a tree with its trunk (Core) consisting of different subsystems (Subsystems) and branches of changeable behavior (Behaviour) diverging from it. And next to it there will be a binoculars (Reporting, GUI) to look at the tree from the necessary angle and an axe and a chainsaw (Actions, GUI) to provide us with the necessary interaction with the tree.

 
Простые стейт-машины на службе у разработчика
Простые стейт-машины на службе у разработчика
  • habrahabr.ru
Представьте на минутку обычного программиста. Допустим, его зовут Вася и ему нужно сделать анимированную менюшку на сайт/десктоп приложение/мобильный апп. Знаете, которые выезжают сверху вниз, как меню у окна Windows или меню с яблочком у OS X. Вот такое. Начинает он с одного выпадающего окошка, тестирует анимацию, выставляет ease out 100% и...
 
Give at least a rough example to apply to our realities.
 
FAQ:
Give at least an approximate example to apply to our realities.
You're really something :) The implementation of any strategy is essentially a state machine.
 
TheXpert:
You're really something :) The implementation of any strategy is essentially a state machine.
This is understandable. I asked for an example of such a machine in light of an article on harabra.
 
FAQ:
I understand. I asked for an example of such a machine in the light of the article on charabra.

Oh, okay. There was an article where the dude made an "analogue" of a state machine. And he was pushing this technology as a cutting-edge programming innovation.)

But I can't recall any substantive article on state machines here. I don't recall it here.

 
FAQ:
Give at least a rough example as applied to our realities.

Ahaha, reminds me of "what will be your evidence".

Just googled "state machine", picked out the content I liked best and uploaded it here.

Not proving anything, not disproving anything. Interesting article.

In general, I'm against dogmas. If one person uses it, it doesn't mean it will suit another one.

But when reading somebody else's code I often come across analogies with state machines. Just an observation.