Discussion of article "Creating Multi-Expert Advisors on the basis of Trading Models" - page 4

 

Thank you very much to the author for the article and the code. Today I redesigned the code of a simple Expert Advisor for the model class. After some efforts I managed to achieve parallel work on different pairs and timeframes.

The only thing I had to correct in the code was to slightly modernise the GetMyPosition() function so that it counts the volume only by the symbol passed as a parameter. Otherwise, a model working on a bundle of two or more pairs when calling GetMyPosition() gets the total volume for several pairs instead of the required separate volume for each pair. I also added a method to the CTableOrders class to get the order symbol.

string            OrderSymbol(){return(m_symbol);}


Thanks again!

 

Thank you, friends, for the appreciation of my work! It is pleasant to realise that the issues I am considering are relevant and necessary. Let us not enter into polemics with illiterate critics. They will always be there and they will not be persuaded even in obvious things.

H.Y. It is better to overload the double GetMyPosition() method accordingly: double GetMyPosition(string Symbol). It will give you more flexibility and versatility.

Undoubtedly, the code will be improved and changed over time, because it is impossible to take into account all possible areas of its application at once.

Thanks again, and Happy New Year 2011! Happiness and good luck!

 
Огромное спасибо автору за статью, обязательно возьму себе на вооружение.
 

Thanks Vasily for the article - in my opinion this is the best approach so far. It's just incredible how you could debug this code.

Vasily - how did you debug this code without a debugger in a tester ? I find it very difficult to work without a debugger in a tester - because signals are different and under different conditions.

Share your experience of debugging.

 

 Hallo. Respekt for this great Tutorial.Verry big praise at you.

I've debugged this Code and find an error at Line 355 in Model.mqh
   

switch(op_type)
 {
 case ORDER_TYPE_BUY:
 case ORDER_TYPE_SELL:
 rez=m_trade.PositionOpen(m_symbol,op_type,lot_send,price,0.0,0.0,comment);
 break;

under ORDER_TYPE_BUY: is none Funktion.Is that right?No function by Buy?
I've changed the code in:

   
switch(op_type)
 {
 case ORDER_TYPE_BUY:
 rez=m_trade.PositionOpen(m_symbol,op_type,lot_send,price,0.0,0.0,comment);
 break;
 case ORDER_TYPE_SELL:
 rez=m_trade.PositionOpen(m_symbol,op_type,lot_send,price,0.0,0.0,comment);
 break;


But, in Jornual you see, he hasn't long Position only short.


ea_modelclass



I don't find the error.need Help.


MfG Christian

Files:
logfile.txt  100 kb
 
After the latest terminal updates the model stopped working. Can someone explain what happened?
 
YYURIYY:
After the latest terminal updates the model stopped working. Can someone explain what happened?


Likewise. I have been parsing the code comma by comma for a week. The strategy places sell orders, but the GetNumberOrders() function returns only sell orders = 0, but buy orders = 1.

I would like to ask Vasily, as the developer of this code, to help me. I can't figure out what the reason is yet.

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 

Compliments for this article!!

I am glad more people thing about this idea. Once before a time I tryied to develop multicurrency multistrategy EA template in MQL4

Since MQL5 is here I was trying to design object model of such an EA and to start implement it

Unfortunatelly no free time for these activities... :-(

please keep on this project...that is the way I think... to have a framework, where it is possible to implement easily a lot of strategies and with possibility to switch on/off any of them, manually or even automatically. So we can have a portfolio of EA's and even add or remove some EA's if it is required.

Thanks for this!! 

PS: here is a link if you would be interested in...

https://www.mql5.com/en/forum/118148 

Cooperation on interesting projects: TRENDLINE AUTOTRADER and UNIVERSAL MULTICURRENCY MULTISTRATEGY TRADER TEMPLATE - MQL4 forum
  • www.mql5.com
Cooperation on interesting projects: TRENDLINE AUTOTRADER and UNIVERSAL MULTICURRENCY MULTISTRATEGY TRADER TEMPLATE - MQL4 forum
 
YYURIYY:
After the latest terminal updates the model stopped working. Can someone explain what happened?

I think I figured it out. In the code you need to change :

#property copyright "Copyright 2010, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"

#include <Trade\_OrderInfo.mqh>
#include <Trade\_HistoryOrderInfo.mqh>
#include <Arrays\List.mqh>
class CTableOrders : CObject
{
private:
   ulong             m_magic;       // Magik of the expert who issued the order
   ulong             m_ticket;      // Ticket of the main order
   ulong             m_ticket_sl;    // Ticket of the buyback order of the trade executed on the basis of the main order (Stop Loss)
   ulong             m_ticket_tp;    // Ticket of the buyback order of the trade executed on the basis of the main order (Take Profit)
   ENUM_ORDER_TYPE   m_type;         // Main order type
   datetime          m_time_setup;  // Order setting time
   double            m_price;       // Order price
   double            m_sl;          // Suggested Stop Loss price
   double            m_tp;          // Price of estimated Take Profit
   double            m_volume_initial;      // Order volume
public:
                     CTableOrders();
   bool              Add(COrderInfo &order_info, double stop_loss, double take_profit);
   bool              Add(CHistoryOrderInfo &history_order_info, double stop_loss, double take_profit);
   double            StopLoss(void){return(m_sl);}
   double            TakeProfit(void){return(m_tp);}
   ulong             Magic(){return(m_magic);}
   ulong             Ticket(){return(m_ticket);}
   int               Type() const;
   datetime          TimeSetup(){return(m_time_setup);}
   double            Price(){return(m_price);}
   double            VolumeInitial(){return(m_volume_initial);}
};

CTableOrders::CTableOrders(void)
{
   m_magic=0;
   m_ticket=0;
   m_type=0;
   m_time_setup=0;
   m_price=0.0;
   m_volume_initial=0.0;
}

bool CTableOrders::Add(CHistoryOrderInfo &history_order_info, double stop_loss, double take_profit)
{
   if(HistoryOrderSelect(history_order_info.Ticket())){
      m_magic=history_order_info.Magic();
      m_ticket=history_order_info.Ticket();
       m_type=history_order_info.OrderType();
      m_time_setup=history_order_info.TimeSetup();
      m_volume_initial=history_order_info.VolumeInitial();
      m_price=history_order_info.PriceOpen();
      m_sl=stop_loss;
      m_tp=take_profit;
      return(true);
   }
   else return(false);
}

bool CTableOrders::Add(COrderInfo &order_info, double stop_loss, double take_profit)
{
   if(OrderSelect(order_info.Ticket())){
      m_magic=order_info.Magic();
      m_ticket=order_info.Ticket();
      m_type=order_info.OrderType();
      m_time_setup=order_info.TimeSetup();
      m_volume_initial=order_info.VolumeInitial();
      m_price=order_info.PriceOpen();
      m_sl=stop_loss;
      m_tp=take_profit;
      return(true);
   }
   else return(false);
}

int   CTableOrders::Type() const
{
   return((ENUM_ORDER_TYPE)m_type);
}
 

The scope of this article is vast and *very* well thought out.

I can't tell you in words how much I appreciate your efforts on building this framework; you also explained the reasoning behind your approach to an understandable level (at least to me!). This article goes much further than concepts, I agree - this is practical, proper, most importantly prudent application of trading and OO programming techniques!

A request - can your comments in the english files be translated? Further, can somebody direct me to tools for further working with Russian language? The comments in MetaEditor do not even appear as Russian language, rather as garbled accented characters not much different from this example:

 // Èíèöèàëèçèóðóåì óêàçàòåëü ìîäåëüþ MACD

I have been using Chrome+Google Translate to view the Russian site for some time now, but on longer articles (especially this one) I can only get a finite length of the document translated. I was very anxious to read in full depth this article and had to wait some time, which, to me at least, was hardly tolerable! Any advice on becoming more foreign-language-friendly will be accepted with high regard!

A masterpiece, Mr. Sokolov. My compliments and gratitude I send to you for your work, and I look forward to implementing my visions for this great approach to trading systems. You have solved many conflicts I had while trying to design a system which might handle my requirements of the system I ultimately want to trade. For the remaining problems yet to be resolved, this framework leads my efforts in the right direction by design.