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

 

MetaTrader 5 Client Terminal build 381

...

MQL5: The standard library was updated: the Type() methods of CDealInfo, CHistoryOrderInfo, COrderInfo and CPositionInfo classes were renamed into DealType(), OrderType() and PositionType(), respectively.

...


Since the model relies on the base trade classes, any, even minor changes in their interfaces are critical. In this case, the error can be easily fixed by simply changing the Type() method to the corresponding OrderType() in the TableOrders.mqh file.

In the near future, the codes attached to the article will be updated to work correctly on the latest builds of the compiler and terminal.

 

chr1sch4n:    There is no error...  your code you've re-written is identical. 

In C language,  case statements fall through, which is why you have to put in the break statement, so therefore the Buy should fall through to the next statement and still execute the order.

refer: http://en.wikipedia.org/wiki/Switch_statement  ;    section C, C++, Java, PHP, ActionScript, JavaScript;   "this is a classic example of omitting the break line to allow for fall through"

 

cheers

 
Lugner:

A request - can your comments in the english files be translated?

Fixed. Thank you.
 
One of the best articles I have read, Thank you very much. 
 

I dont seem to get the impressive backtest shown in the article.  what are the settings I need to do?

 

"It is worth describing them_timing variable separately. In the course of the Expert Advisor's work it is required to call certain events at certain time intervals.The OnTimer() functionis not suitable for this, because different models may have different time intervals.

For example, some events need to be called every new bar. For a model trading on an hourly chart, such events should be called every hour, for a model trading on a daily chart - every new daily bar. It is clear that these models have different time settings and each should be stored in its own model accordingly. The t_period structure included in the CModel class allows storing these settings separately, each in its own model.

Here is what this structure looks like:

struct t_period
{
 большая структура 
};

As you can see, it includes the usual enumeration of timeframes. To find out whether a new bar has occurred, we need to compare the time of the last bar with the time recorded in the t_period structure. If the time does not coincide, then a new bar has occurred, the time in the structure should be updated to the time of the current bar and return a positive result (true). If the time of the last bar and the structure coincide, it means that a new bar has not yet occurred and we just need to return a negative result (false).

Here is a function that works according to the described algorithm:

bool timing(string symbol, ENUM_TIMEFRAMES tf, t_period &timeframes)
{
большой swich
} 

"

I am, of course, only a novice programmer, but maybe it is possible to determine the onset of a new bar to do so (while making the variable m_timing just datetime):

If I am wrong with the conclusions, I apologise in advance and ask you to correct me. If I am not mistaken - I thank this site and in particular all those who work here - articles, documentation writes - I began to understand something.

bool timing(string symbol, ENUM_TIMEFRAMES tf, t_period &timeframes)
{
   int rez;
   MqlRates raters[1];
   rez=CopyRates(symbol, tf, 0, 1, raters);
   if(rez==0)
   {
      Print("Error timing");
      return(false);
   }
   if (TimeCurrent()-raters.time)>PeriodSeconds(tf) return(true); else return(false);
   
} 


P.S.:By the way, thanks for a great article.

 

Hi,

how can I enhance model or Processing() function to support pair trading (another symbol)? Now everything works with indicator and subsequent trading on the same Symbol only. How can I add Symbol1 and Symbol2 to be able to buy Symbol1 and sell Symbol2 simultaneously?

Thanks for help

P.S.: Or buy/sell Symbol1 based on behavior of indicator on Symbol2...

 
P_Cherry:

Hi,

how can I enhance model or Processing() function to support pair trading (another symbol)? Now everything works with indicator and subsequent trading on the same Symbol only. How can I add Symbol1 and Symbol2 to be able to buy Symbol1 and sell Symbol2 simultaneously?

Thanks for help

P.S.: Or buy/sell Symbol1 based on behavior of indicator on Symbol2...

I hope it is possible?
 
Automated-Trading:
Fixed. Thank you.
thanks.
 

Hi,

Thanks for this great article...

In the function ReplacedDelayedOrders is the code line:   for(int b=0;i<history_orders;b++)

I think this will cause an endless loop, or am I wrong?

I think the code line must be:   for(int b=0;b<history_orders;b++)

 

Bye, T.