Discussing the article: "Developing a multi-currency Expert Advisor (Part 1): Collaboration of several trading strategies" - page 3

 
Yuriy Bykov #:

I'm in the process of redesigning almost from scratch my previously written code over the last few years

When refactoring, you always want to do it in such a way that you won't have to redo it later and it will be convenient/perspective.

Child( const string sInputs ) : Parent(sInputs)
{
  this.SetInputs(sInputs);
}

virtual int SetInputs( const string sInputs )
{
  return(this.Inputs.FromString(sInputs) + this.Parent::SetInputs(sInputs));
} 

As a result, I came to this solution of working with inputs.

 
fxsaber #:

When refactoring, you always want to make it so that you don't have to redo it later and it's convenient/perspective.

It seems architecturally promising when CStrategy is divided into three entities: the trading core (gives signals), the trading part (trades signals) and MM

class CSimpleVolumeStrategy : public CStrategy {
private:
   //---  Параметры сигнала к открытию
   int               signalPeriod_;       // Количество свечей для усреднения объемов
   double            signalDeviation_;    // Относ. откл. от среднего для открытия первого ордера
   double            signaAddlDeviation_; // Относ. откл. от среднего для открытия второго и последующих ордеров

   //---  Параметры отложенных ордеров
   int               openDistance_;       // Расстояние от цены до отлож. ордера
   double            stopLevel_;          // Stop Loss (в пунктах)
   double            takeLevel_;          // Take Profit (в пунктах)
   int               ordersExpiration_;   // Время истечения отложенных ордеров (в минутах)

   //---  Параметры управление капиталом
   int               maxCountOfOrders_;   // Макс. количество одновременно отрытых ордеров

Here we have all of them together. But it is convenient when you can change the same core (new Core2 instead of new Core1) with other inputs. At the same time, the replacement can be done without any fiddling with the inputs, because they are defined syntactically in the same way - a string.


Similarly with control and MM. In general, I propose to think again about a universal architecture.

 
fxsaber #:
It seems architecturally promising, when CStrategy is divided into three entities: trading core (gives signals), trading part (trades signals) and MM....

It seems that this approach is already implemented in SB - CExpert class.

And there is even a CStrategy class by Vasily Sokolov ))

Документация по MQL5: Стандартная библиотека / Модули стратегий / Базовые классы экспертов / CExpert
Документация по MQL5: Стандартная библиотека / Модули стратегий / Базовые классы экспертов / CExpert
  • www.mql5.com
CExpert - Базовые классы экспертов - Модули стратегий - Стандартная библиотека - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 

I saw the standard CExpert class, but it didn't work for me. It added too much that I didn't need. The inheritance hierarchy was also a bit discouraging, when the base class for implementing money and risk management algorithms and the base class for creating generators of trading signals are inherited from the same base class.

I have not seen Vasily Sokolov's series of articles, thanks for the link, I will have a look.

 
Denis Kirichenko #:

So already, it seems, such an approach is implemented in SB - class CExpert.

It seems that the task of integration into the Strategy Wizard was solved there. That is, the initial approach is quite different. Certainly, there are some overlaps, but it is rather a coincidence.

 
Denis Kirichenko #:

And there is even a CStrategy class by Vasily Sokolov ))

It seems to me that the architectural skeleton should be extremely concise and easy to use. That's why the basic class of TS is like this.

Next, a little tendon fattening. It should be very simple.

Unfortunately, Vasily has a different approach.

 
fxsaber #:

It seems to me that the architectural skeleton should be extremely concise and easy to use. That's why the basic class of TC is like this.

Next, a little fleshing out of the tendons. It should be very simple.

There is something similar simple (in terms of interface) but extended (in terms of implementation) in the book.

interface TradingSignal
{
   virtual int signal(void);
};

interface TradingStrategy
{
   virtual bool trade(void);
};

...
...
AutoPtr<TradingStrategy> strategy;
   
int OnInit()
{
   strategy = new SimpleStrategy(
      new BandOsMaSignal(...параметры...), Magic, StopLoss, Lots);
   return INIT_SUCCEEDED;
}
   
void OnTick()
{
   if(strategy[] != NULL)
   {
      strategy[].trade();
   }
}
...
Учебник по MQL5: Автоматизация торговли / Тестирование и оптимизация экспертов / Большой пример эксперта
Учебник по MQL5: Автоматизация торговли / Тестирование и оптимизация экспертов / Большой пример эксперта
  • www.mql5.com
Автоматизация торговли - Программирование на MQL5 для трейдеров - Учебник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Stanislav Korotky #:

There is something similarly simple (in terms of interface) but extended (in terms of implementation) in the book.

Where can I download the source code?

 
fxsaber #:

Where to download the source code?

https://www.mql5.com/ru/code/45595

Программирование на MQL5 для трейдеров — исходные коды из книги. Часть 6
Программирование на MQL5 для трейдеров — исходные коды из книги. Часть 6
  • www.mql5.com
В шестой части книги "Программирование на MQL5 для трейдеров" мы изучим ключевую составляющую языка MQL5 — автоматизацию торговли. Начнем с описания основных сущностей, таких как спецификации финансовых инструментов и настройки торгового счета, которые необходимы для создания корректных советников.
 
Very interesting strategy!!