Errors, bugs, questions - page 737

 
-Alexey-:
Why when I press "Start" button the tester does not test from the initial deposit level, but from the level where the last test ended. There is no such a problem in 4. How to start testing from the initial deposit level?

We cannot reproduce the situation you describe.

Let's give more details

 
stringo:

We cannot reproduce the situation you describe.

Give us more details

I generate a parabolic in the wizard on the average with a stop. I run a test on open prices, click "Cancel". I run it for the second time and get the situation described above (balance and equity chart is not drawn anew but continues). Expert Advisors not from the Wizard are OK.
Мастер MQL5: Создание эксперта без программирования
Мастер MQL5: Создание эксперта без программирования
  • 2010.12.15
  • MetaQuotes Software Corp.
  • www.mql5.com
Вы хотите быстро проверить торговую идею, не тратя времени на программирование? Выберите в "Мастере MQL5" нужный тип торговых сигналов, подключите модули сопровождения позиций и управления капиталом - на этом вся работа закончена. Создайте свои реализации модулей или закажите их через сервис "Работа" - и комбинируйте новые модули с уже существующими.
 

This seems to be a bug.

In multicurrency testing mode, when waiting for a new bar to appear on two instruments, the tester does not behave correctly.

A little clarification. In the isNewBar function, when a new bar appears on the main symbol, we wait for a new bar to appear in the loop on the other symbol.

I am pasting the code.

//в тестере баг в режиме мультивалютного тестирования
//позиция открывается если на двух инструментах появился новый бар 
#include <Trade\Trade.mqh>
#include <Trade\OrderInfo.mqh>
#include <Trade\PositionInfo.mqh>
//--- input parameters
input int      Per=10;//период средней 
input string   Instrum1="EURUSD";//первый инструмент
input string   Instrum2="GBPUSD";//второй инструмент
//-------------------------------------------------------
CTrade   trade;//торговые функции
COrderInfo orderinfo;//информация об ордере
CPositionInfo  posinfo;//информация о позиции
int hiMA ;//хэндл индикатора 
int OnInit()
  {
      hiMA=iMA(_Symbol,_Period,Per,0,MODE_SMA,PRICE_OPEN) ;
      if(hiMA < INVALID_HANDLE) return(-1) ;
      return(0);
  }
//====================================================================
void OnDeinit(const int reason)
  {
   IndicatorRelease(hiMA) ;
  }
//=====================================================================
void OnTick()
  {
      if(!isNewBar(Instrum2)) return   ;
      //Print("  Это новый бар  ");
      double   Ma[1] ;//показания индикатора 
      CopyBuffer(hiMA,0,0,1,Ma) ;
      MqlTick price;// будет использоваться для получения текущих/последних котировок цены
      bool possel=posinfo.Select(Instrum1) ;
      SymbolInfoTick(Instrum1,price) ;
      if(possel && price.bid > Ma[0] && posinfo.PositionType() == POSITION_TYPE_SELL)
         {//цена выше средней закрываем короткую позу
            trade.PositionClose(Instrum1) ; return ;
         }
      if( !possel && price.bid > Ma[0])
         {//цена выше средней нет поз открываем длинную позу 
            trade.Buy(0.1,Instrum1,0,0,0,NULL) ; return ;
         }
      if( possel && price.ask < Ma[0] && posinfo.PositionType() == POSITION_TYPE_BUY)
         {//цена ниже средней закрываем длинную позу
            trade.PositionClose(Instrum1) ; return ;
         } 
      if(!possel && price.ask < Ma[0])
         {// цена ниже средней нет поз открываем короткую позу
            trade.Sell(0.1,Instrum1,0,0,0,NULL) ;
         }
      return ;
  }
//=======================================================================
bool isNewBar(string other_symbol)
  {//возвращает труе если новый бар на двух инструментах
   static datetime last_bar_time=0;
   int cntsleep ;
   if(last_bar_time==0)
     {//--- это первый вызов, запишем время открытия и выйдем
      last_bar_time=(datetime)SeriesInfoInteger(_Symbol,Period(),SERIES_LASTBAR_DATE);
      return(false);
     }
   datetime curr_time=(datetime)SeriesInfoInteger(Symbol(),Period(),SERIES_LASTBAR_DATE);
   if(curr_time!=last_bar_time)
     {//время открытия не совпадает это новый бар 
      last_bar_time=curr_time;
      cntsleep=0 ;
      while(!(curr_time == (datetime)SeriesInfoInteger(other_symbol,Period(),SERIES_LASTBAR_DATE)))
         {// ждем появления нового бара на втором инструменте   
            Sleep(5000); 
            if(cntsleep >10) return(false) ;// недождались 
            cntsleep++ ;
         }
      return(true) ;
     }
    return(false) ;
  }
Обработчик события "новый бар"
Обработчик события "новый бар"
  • 2010.10.04
  • Konstantin Gruzdev
  • www.mql5.com
Язык программирования MQL5 позволяет решать задачи на совершенно новом уровне. Даже те задачи, которые уже вроде имеют решения, благодаря объектно-ориентированному программированию могут подняться на качественно новый уровень. В данной статье специально взят простой пример проверки появления нового бара на графике, который был преобразован в достаточно мощный и универсальный инструмент. Какой? Читайте в статье.
 
ivandurak:

This seems to be a bug.

In multi-currency test mode, when waiting for a new bar to appear on two instruments, the tester does not behave correctly.


What exactly do you see as a bug, please explain. You have not given any details of the testing, or the result obtained, or the expected result.

In addition, I would like to draw your attention to the Basics of Testing in MetaTrader 5. It explains the mechanism of tick generation and basic concepts.

 
Rosh:

What exactly do you see as a bug, please explain. You haven't provided any details of testing or the result you've got, and you don't know the expected result.

In addition, I would like to draw your attention to the Basics of Testing in MetaTrader 5. It explains the mechanism of tick generation and basic concepts.

It's easy.

We start the Expert Advisor for optimization and see the result.

For example, we choose the 4th pass, run the Expert Advisor, and get its normal operation with all trades - here is the report.

I have a feeling. In the multi-currency optimization mode the tester cannot bind a trade to the bar if it was not opened on the open bar.

If the isNewBar function has commented out the loop and does not wait for the appearance of a new bar on another symbol, everything works. Terminal version 5 build 642.

I have read the articles and the codes from there. Although, I know myself, I may have to reread them.

Happy Holidays.

 
-Alexey-:
I generate in the wizard an EA on medium with a stop parabolic. I run a test on open prices and click "cancel". I run it for the second time and get the situation described above (balance and equity chart is not drawn again but continues). Expert Advisors not from the Wizard are OK.

Create a servicedesk application, specifying

  • build number
  • The system bit mode and Windows version.
  • enclose code of the Expert Advisor
  • settings and input parameters of the EA
 

Here is a piece of code. How to make the parametersinput int grusdchf=100; input int grusdjpy=100; not to be optimised whentrpar2=false

//------------------------------------------------------------
input bool  trpar1=true ;//разрешение торговли по EURUDSD
input int   greurusd=100;//сетка для EURUSD
input int   grgbpusd=100;//сетка для GBPUSD
//------------------------------------------------------------
input bool  trpar2=true;//
input int   grusdchf=100;//
input int   grusdjpy=100;//
//------------------------------------------------------------
input bool  trpar3=true;//
input int   graudjpy=100;//
input int   grchfjpy=100;//
 
ivandurak:

Here is a piece of code. How to make the parametersinput int grusdchf=100; input int grusdjpy=100; not to be optimised whentrpar2=false

Do not check the checkboxes in the tester against these parameters. Or clarify the question, otherwise I see ambiguity. :)

 

Question:

You need to pass an array of object pointers to a function. By reference, of course (an array).

What syntax to use?

void MyFunc(MyClass &*MayClassPointersArray[]);  / не компилируется.
void MyFunc(MyClass *&MayClassPointersArray[]);  / компилируется, но сомневаюсь что смысл правильный

Or should I use it in some other way?

 
ivandurak:

Here is a piece of code. How to make the parametersinput int grusdchf=100; input int grusdjpy=100; not to be optimised whentrpar2=false

input bool trpar2=true;
input int grusdchf=100;
input int grusdjpy=100;

if (trpair2==false)  // если false то всегда 100
  {
   x_grusdchf=100;
   x_grusdjpy=100;
  }
 else                // если true то значения с перебора 
  {
   x_grusdchf=grusdchf;
   x_grusdjpy=grusdjpy;
  }
The checkboxes are enabled on all three inputs and then locks at false.
Reason: