MetaTrader 4 Build 529 beta released with new compiler - page 18

 
mr_Johns:
Has the MQL4 handbook (which is in the editor) also been updated accordingly?


yes with a request to update. The MQL4handbook is almost based on 5 and does not correspond to the compiler's realities at the moment.
 
ALXIMIKS:

Correct me if I got it wrong.

I use a library function in an indicator, this function declares some static variables that participate in the calculation of the indicator array.

If I want to change the indicator parameters in order to correct indicator calculation (depending on static variables),

pass the flag to the library function that is responsible for reinitialization (you should expand the input parameters of each function that has static variables)

make zeroing of static variables in the body, and do not forget to remove the flag before completing the calculation.

It would be much easier if static variables had some parameter, set during their declaration, responsible for whether these variables will be reset to zero during reinitialization.

Make global variables instead of local statics (outside of functions), and initialise them on the first call.
 
ALXIMIKS:

It would be much simpler if static variables had some parameter to be set when they are declared, responsible for whether or not the value of these variables would be reset on reinitialization.

It would be even easier, if developers make special function like ResetStaticVars().

// By the way, it's not so easy to do. I wouldn't. It's one thing to simply zeroize the entire data segment, and another thing is to correctly assign all user initial values. A pain in the neck, though.

Actually (as a paradigm) saving values during the life of the program is rather convenient. There is just a question of backward compatibility here, so...

 

I know that this is a Russian speaking part of the forum, but since I am bad at talking Russian (even though I can read it) hope nobody will mind posting this here (since the English part seems completely inactive as far as these issues are concerned and since I did not see that someone posted about this issue)

There is one serious issue with the new metatrader that concerns external string parameters. Initially they have a correct value, but as soon as time frame or symbol is changed the content of a string parameter is lost. Here is a simple example that will show exactly what is happening. That issue also happens when such indicators are used through iCustom() call and that makes any such indicator unusable from any EA or other code

#property indicator_chart_window

extern string TestString = "whatever value that we want initially set";

int OnInit() { return(0); }
int deinit() { return(0); }
int start()
{
   Comment(TestString);
   return(0);
}
 
ALXIMIKS:

Yes with the update request. The handbook for MQL4
is almost based on 5 and doesnot correspond to the realities of the compiler at the moment.

maybe they left something there that is in the near future? i'm counting on it.
 
mr_Johns:
Has the MQL4 handbook (which is in the editor) also been updated accordingly?

Yes, it has been updated a long time ago and is actively supplemented on a daily basis.
 

I can't figure out why we need a design like this

#property icon "\\Files\\button.ico"
 
VOLDEMAR:

I can't figure out why we need a design like this

When you start the EA, there will be a picture on the "General" tab.
 
no picture
 
mladen:

I know that this is a Russian speaking part of the forum, but since I am bad at talking Russian (even though I can read it) hope nobody will mind posting this here (since the English part seems completely inactive as far as these issues are concerned and since I did not see that someone posted about this issue)

There is one serious issue with the new metatrader that concerns external string parameters. Initially they have a correct value, but as soon as time frame or symbol is changed the content of a string parameter is lost. Here is a simple example that will show exactly what is happening. That issue also happens when such indicators are used through iCustom() call and that makes any such indicator unusable from any EA or other code

Mladen, it's easier for me to answer in Russian, since you are fluent in reading.

Here is my solution to this problem. In my init() code I include the ReInit() function which re-initializes those global variables, whose values should be restored when the timeframe or the symbol changes:

//-----------------------------------------------------------------------------
int init(){
   int Error;
   if( МинНаклонТренда<Zero ) МинНаклонТренда=0;
   if( МинНаклонТренда-МаксНаклонТренда>Zero ) МаксНаклонТренда=МинНаклонТренда;
   if( БарОкончания<1 ) БарОкончания=1;
   if( МинБазовыйПериод<1 ) МинБазовыйПериод=1;
   if( МаксБазовыйПериод<МинБазовыйПериод ) МаксБазовыйПериод=МинБазовыйПериод;
   if( БарНачала<МинБазовыйПериод+БарОкончания ) БарНачала=МинБазовыйПериод+БарОкончания;
   if( БарНачала>Bars-1 ){
      if( Bars>МинБазовыйПериод+БарОкончания ) БарНачала=Bars-1;
      else Alert("Неразрешимая ошибка: история("+Bars+")<=активация("+МинБазовыйПериод
                +")+окончание("+БарОкончания+")");
   }
   if( ТолщинаТрендовой<1 ) ТолщинаТрендовой=1;
   if( ТолщинаТрендовой>5 ) ТолщинаТрендовой=5;
   if( РазмерИндикатораТиков<1 ) РазмерИндикатораТиков=1;
   if( РазмерИндикатораТиков>5 ) РазмерИндикатораТиков=5;
   if( СдвигИндикатораТиков<3 ) СдвигИндикатораТиков=3;
   if( СдвигИндикатораТиков>100 ) СдвигИндикатораТиков=100;
   if( ПоказыватьВсе ) Visibility=0; else Visibility=EMPTY;
   LastBar     =БарОкончания;
   ЦветЛиний[0]=ЦветПоддержки;
   ЦветЛиний[1]=ЦветСопротивления;
   ЦветХорды[0]=ЦветВосходящейХорды;
   ЦветХорды[1]=ЦветНисходящейХорды;
   Цвет123[0]  =Цвет123 ВТ;
   Цвет123[1]  =Цвет123 НТ;
   NewTime     =0;
   ReInit();                                       // Повторная инициализация
   ClearScreen();                                  // Очистить экран
   Error=fVLine("StartLine","Старт",0,БарНачала,0,0,0,0,0,ЦветВертикалей);
   Error=fVLine("DeadLine","Пуск",0,БарОкончания,0,0,0,0,0,ЦветВертикалей);
   DeadLine=TimeCurrent();
   if( СтатическийРежим ){
      if( РежимОтладки ) РежимРаботы=" Отладка "; else РежимРаботы=" ";
      РежимРаботы=РежимРаботы+"Статический режим Пауза "+ПериодИмитацииТиков+" мс";
      МоделироватьДинамику=false;
      //РежимОтладки=false;
      while( true ){                               // Бесконечный цикл
         ReInit();                                 // Повторная инициализация
         start();                                  // Имитация тика
         Sleep(ПериодИмитацииТиков);               // Не работает в индикаторах
   }  }
   else {
      if( МоделироватьДинамику ){
         РежимРаботы=" Режим имитации динамики Размерность "+DoubleToStr(0.5*БарНачала*БарНачала,0);
         Print("      "+Version+РежимРаботы+" История: "+(БарНачала)+" баров с "+TimeToStr(Time[БарНачала]));
         LastBar=БарНачала;
         while( LastBar>БарОкончания ){            // Перебор всех баров истории
            LastBar--;
            start();                               // Имитация тика
         }
         МоделироватьДинамику=false;
         Print("      Режим имитации динамики отключен!");
   }  }
   if( РежимОтладки ) РежимРаботы=" Отладка "; else РежимРаботы=" ";
   РежимРаботы=РежимРаботы+"Динамический режим";
   Print("      "+Version+РежимРаботы+" История: "+(БарНачала)+" баров с "+TimeToStr(Time[БарНачала]));
   if( !ПечататьПредупреждения ) Print("Печать предупреждений запрещена!");
   if( РежимОтладки ) start();                     // Имитация тика
   return(0);
}
//-----------------------------------------------------------------------------
// Повторная инициализация глобальных переменных и массивов
void ReInit(){
   StartTime[0]   =Time[БарНачала];
   StartTime[1]   =Time[БарНачала];
   Groups[0]      =0;
   Groups[1]      =0;
   OldMG[0]       =0;
   OldMG[1]       =0;
   MainGroup[0]   =0;
   MainGroup[1]   =0;
   QualityMax[0]  =0;
   QualityMax[1]  =0;
   OldStopLine    =0;
   return;
}
//-----------------------------------------------------------------------------
Reason: