Errors, bugs, questions - page 214

 
Ashes:

Let me remind you, the result was obtained with a simple Expert Advisor, which practically does not spend time on any analysis and does not use indicators, i.e. the results would have been even sadder with a working EA.

Please post the code of the EA.
 
Ashes:

Let me remind you, the result was obtained on a simple Expert Advisor, which practically does not spend time on any analysis and does not use indicators, i.e. the results would be even sadder on a working Expert Advisor.

For comparison:

Running this test with 10000 trades on a Windows 7 machine, Intel Pentium Dual-Core E5400 @ 2.70 GHz, 2038 MB (PR111) took 472866ms.

In the light of the above, there is some probability that some of the candidates for the Championship 2010 could have been unjustly eliminated because of the 15-minute barrier and peculiarities of the tester (if there were a lot of deals).

** - there were several times when the tester failed to display the symbol chart with trades displayed at the end of the test.

I was not able to write a "simple EA" that would show such results. Here is my code:

//+------------------------------------------------------------------+
//|                                                  TimeOnDeals.mq5 |
//|                        Copyright 2010, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
//--- input parameters
input int      deals=1000;
input double   lot=0.01;
uint start;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   start=GetTickCount();
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   PrintFormat("deals=%d  time=%d",deals,(GetTickCount()-start));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double OnTester()
  {
   return(GetTickCount()-start);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   static int done_deals=0;
//---
   if(done_deals<deals)
     {
      if(Buy(lot)) done_deals++;
      else Print("Не удалось выполнить Buy, ошибка ",GetLastError());
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool Buy(double v)
  {
   double price=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
   MqlTradeRequest   m_request;         // request data
   MqlTradeResult    m_result;          // result data   
   m_request.action=TRADE_ACTION_DEAL;
   m_request.symbol      =_Symbol;
   m_request.magic       =555;
   m_request.volume      =v;
   m_request.type        =ORDER_TYPE_BUY;
   m_request.price       =price;
   m_request.sl          =0;
   m_request.tp          =0;
   m_request.deviation   =10;
   return(OrderSend(m_request,m_result));

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
bool Sell(double v)
  {
   double price=SymbolInfoDouble(_Symbol,SYMBOL_BID);
   MqlTradeRequest   m_request;         // request data
   MqlTradeResult    m_result;          // result data   
   m_request.action=TRADE_ACTION_DEAL;
   m_request.symbol      =_Symbol;
   m_request.magic       =555;
   m_request.volume      =v;
   m_request.type        =ORDER_TYPE_SELL;
   m_request.price       =price;
   m_request.sl          =0;
   m_request.tp          =0;
   m_request.deviation   =10;
   return(OrderSend(m_request,m_result));
  }
//+------------------------------------------------------------------+


Here are the optimisation results, the Result column shows the run time in milliseconds.


 
Rosh:

I have not been able to write a "simple EA" that shows these results. Here is my code:

Here are the optimisation results, the Result column shows the run time in milliseconds.

Interesting...

Alexander:
EA code please publish.

The Expert Advisor is based on the template from the article How to quickly write an Expert Advisor for the Automated Trading Championship 2010.

The CExpertAdvisor class is used without any changes. Perhaps this is a side effect of using classes? The test results give the impression that the slowdown starts after some threshold is exceeded. Maybe it's a transaction table of a limited size, after which the memory reallocation / rubbish collection starts to take effect?

PS. Once again I would like to remind you that the Expert Advisor uses Alpari-Demo account feature (zero margin), otherwise the number of trades may change.

Files:
 
Rosh:

I have not been able to write a "simple EA" that shows these results. Here is my code:

Here are the optimisation results, the Result column shows the run time in milliseconds.

No problem with output to XLSX either?

 
Rosh:

I have not been able to write a "simple EA" that shows these results. Here is my code:

Here are the optimisation results, the Result column shows the run time in milliseconds.

Table - Optimizer's result: Logging OFF? A side effect of logging?

 
Ashes:


An EA based on the template from the article How to write a quick EA for the Automated Trading Championship 2010.

The CExpertAdvisor class is used without any changes. Perhaps this is a side effect of using classes? The test results give the impression that the slowdown starts after some threshold is exceeded. Maybe it's a transaction table of a limited size, after which the memory reallocation / rubbish collection starts to take effect?

PS. Once again I would like to remind you that the Expert Advisor uses a feature of Alpari-Demo account (zero margin), otherwise the number of trades may change.

This class contains the GetDealByOrder(ulong order) method

ulong CExpertAdvisor::GetDealByOrder(ulong order) // получение тикета сделки по тикету ордера
  {
   PositionSelect(m_smb);
   HistorySelectByPosition(PositionGetInteger(POSITION_IDENTIFIER));
   uint total=HistoryDealsTotal();
   for(uint i=0; i<total; i++)
     {
      ulong deal=HistoryDealGetTicket(i);
      if(order==HistoryDealGetInteger(deal,DEAL_ORDER))
         return(deal);                            // запомнили тикет сделки 
     }
   return(0);
  }

which is called on every trade. Accordingly, each time the entire history of trades is reviewed and there is a slowdown in the testing time which is proportional to the square of the number of trades.

Such things are better not to be used in an Expert Advisor that needs to be optimized or tested, because the time losses are inevitable. It is better to replace these calls algorithmically for these cases.

 
Rosh:

This class contains the GetDealByOrder(ulong order) method

which is called on each transaction. Consequently, each time the entire history of trades is searched and there is a slowdown in testing time, proportional to the square of the number of trades.

You'd better not use such things in the Expert Advisor that needs to be optimized or tested, because you will inevitably lose time. It's better to replace these calls algorithmically for these cases.

I.e., everyone who used the Expert Advisor's template is "affected"...

What about XLSX? It has nothing to do with the Expert Advisor's code, does it?

 
Rosh:

This class contains the GetDealByOrder(ulong order) method

 ulong CExpertAdvisor::GetDealByOrder(ulong order) // получение тикета сделки по тикету ордера
  {
   PositionSelect(m_smb);
   HistorySelectByPosition(PositionGetInteger(POSITION_IDENTIFIER));
   uint total=HistoryDealsTotal();
   for(uint i=0; i<total; i++)
     {
      ulong deal=HistoryDealGetTicket(i);
      if(order==HistoryDealGetInteger(deal,DEAL_ORDER))
         return(deal);                            // запомнили тикет сделки
     }
   return(0);
  } 

which is called at each transaction. Accordingly, in this Expert Advisor under these specified conditions the entire history of transactions is searched each time, and the testing time that is proportional to the square of the number of transactions, is slowing down.

Such things are better not used in an Expert Advisor that needs to be optimized or tested, because time losses are inevitable. It is better to replace these calls algorithmically for these cases.

HistorySelectByPosition(PositionGetInteger(POSITION_IDENTIFIER));

Does this method search the entire history, and not only that part of the history, which is associated with an open position? If I have no more than 5 deals connected with an open position, I think it's better to use HistorySelectByPosition than to look through the entire history HistorySelect(0,TimeCurrent());

P.S. CExpertAdvisor didn't look

 
Konstantin83:

HistorySelectByPosition(PositionGetInteger(POSITION_IDENTIFIER));

Does this method search the whole history? And not only that part of the history, which is connected with an open position? If I have no more than 5 deals connected with an open position, I think it's better to use HistorySelectByPosition than to look through the entire history HistorySelect(0,TimeCurrent());

P.S. CExpertAdvisor didn't look

In this case, we have thousands of deals in one position, and they all have the same POSITION_IDENTIFIER position identifier. Therefore, the call of HistorySelectByPosition in this case is equivalent to the call ofHistorySelect(0,TimeCurrent()), the enumeration of these deals leads to a search of all deals from the history.

Let's say , an unfortunate example of using the pattern from the article was made. It's like in the story about Siberian men and Japanese chainsaw.

 
Ashes:

What about XLSX? It has nothing to do with the EA code?

This place will be fixed. The developers are aware of it, thank you.
Reason: