Errors, bugs, questions - page 2589

 
fxsaber:

Question on ArrayResize. I make a Reserve for several gigabytes at once. Then I gradually increase Size which is less than initial Reserve.

Why does TaskManager show increase of memory consumption during Size increase?

We don't do anything about it on purpose - it's a feature of the OS (and does the user really need gigabytes?

If you want to have "hot" memory at a critical point in a program, you have to "run" through the pages of the allocated chunk before that point, so that the virtual memory pages of the process get physical ones.


But, from MQL, there is no access to the reserved chunk of the array.

 
Ilyas:

We don't do anything for this on purpose - it's a feature of the OS (and does the user really need gigabytes?

If you want to have hot memory at a critical point in a program, you have to "run" through the pages of the allocated chunk before that point, so that the process's virtual memory pages get physical ones.


But, from MQL, there is no access to the reserved chunk of the array.

Thanks. I wonder how the performance should be affected if doing a full ArrayResize on gigabytes at once.

 
void OnStart()
{  datetime m_stoptime = 0;
//1.
   if(m_stoptime < TimeCurrent())
   {
      //расчеты   
   }


//2.
   MqlTick last_tick;
   if(SymbolInfoTick(_Symbol, last_tick))
   {  if(m_stoptime < last_tick.time) 
      {
         //расчеты
      }
   }
//3. 
      const  int start = 0;
      const int count = 1;
      datetime time[1];
      if(CopyTime(_Symbol,PERIOD_M1,start,count,time)>0)
      {
        if(m_stoptime < time[0]) 
         {
         //расчеты
         }
      }
}

Tested, ran a full overshoot while optimising my EA for 5000 passes, counted just from the tester's log

1. 14:04:28.365 - 14:15:47.481 = 11 m 19 sec

2. 13:49:56.885 - 14:00:30.819 = 10 m 34 sec.

3. 14:28:35.89 - 14:41:11.659 = 12 m 36 sec


in principle, as expected option 2 is faster, for 5000 runs the gain is about 30 seconds, also pretty good

 

Please help to call this menu through WinAPI.

I can get the line with the selected EA name. There is only one line in ComboBox, unlike in MT4.

But I can't call the menu. BM_CLICK does not work.


How do you use Messages in x64?


Solved the problem using WM_LBUTTONDOWN.

 
Is it a mistake or not that zero statics are not?
int Array0[] = {};
 
Will there be an option in the mobile terminal to apply indicators from the basement directly to the chart?
 
Igor Makanu:

Basically as expected option 2 is faster, for 5000 passes the gain is about 30 seconds, not bad either.

It would be nice to have a thread where similar results would be compiled. For the Optimizer is relevant.

 
fxsaber:

It would be good to have a branch where similar results would be collected. It's relevant to the Optimizer.

I support it, it's not the first time I've tested and posted results in the middle of nowhere

but I'm not ready to open a branch.... bad education, a sense of responsibility will overwhelm me, but to keep the topic up to date... I'm not sure that I will be able to (((

ZS: following the example above.... yesterday didn't decide to write this thread again in example #2 SymbolInfoTick() toSymbolInfoInteger(_Symbol, SYMBOL_TIME)

ZZZY: here's an example where I use, it's more convenient for me in the optimizer to look for time with a sample rate of 5 minutes - fewer passes, so the time in the optimizer generally made 2 bytes in ushort, if 0 - then this option is not used, I have more - to check how to work with bytes, but not now - in my example once in OnInit() I split bytes - not critical

class CWorkTime
{
private:
   int               m_starthour, m_stophour, m_startmin, m_stopmin;
   datetime          m_starttime, m_stoptime;
   bool              UseThisSession, NotIntraDay;
   void              setTodayWorkTime();
public:
   void              CWorkTime(const ushort worktime);
   bool              Disable(); };
//+------------------------------------------------------------------+
void CWorkTime::CWorkTime(const ushort worktime): UseThisSession(true)
{  union UShortToByte { ushort u_short; uchar byte[2]; } ShortToByte;
   if(worktime == 0)
   {  UseThisSession = false;
      Print("EA working time is not used"); }
   else
   {  ShortToByte.u_short = worktime;
      int t = (int)(ShortToByte.byte[0] * 5.625);
      m_starthour = (int)(t / 60);
      m_startmin = t % 60;

      t = (int)(ShortToByte.byte[1] * 5.625);
      m_stophour = (int)(t / 60);
      m_stopmin = t % 60;
      NotIntraDay = m_starthour > m_stophour ? true : false;
      setTodayWorkTime();
      printf("EA working time start: %d h %d min , end: %d h %d min", m_starthour, m_startmin, m_stophour, m_stopmin); } }
//+------------------------------------------------------------------+
void CWorkTime::setTodayWorkTime()
{  MqlDateTime dtstart, dtstop;
   TimeCurrent(dtstart);
   dtstop         = dtstart;
   dtstart.hour   = m_starthour;
   dtstart.min    = m_startmin;
   dtstop.hour    = m_stophour;
   dtstop.min     = m_stopmin;
   m_starttime    = StructToTime(dtstart);
   m_stoptime     = StructToTime(dtstop);
   if(NotIntraDay) m_stoptime += 86400; }
//+------------------------------------------------------------------+
bool CWorkTime::Disable(void)
{  bool result    = false;
   if(UseThisSession)
   {  datetime time = (datetime)SymbolInfoInteger(_Symbol, SYMBOL_TIME);
      if(m_stoptime < time) setTodayWorkTime();
      result      = time >= m_starttime && time <= m_stoptime ? false : true; }
   return(result); };
//+------------------------------------------------------------------+

usage:

int OnInit()
  {
   WorkTime=new CWorkTime(EA_Time);
   }

void OnTick()
  {
    bool DisableTradingByTime=WorkTime.Disable();
.....
    if(DisableTradingByTime) return;

i.e. the result of the Disable() method - très not working time, falce - working

 
fxsaber:

It would be good to have a branch where similar results would be collected. It is relevant for the Optimiser.

There is a similar one on the subject:

Алгоритмы, методы решений, сравнение их производительности
Алгоритмы, методы решений, сравнение их производительности
  • 2017.12.10
  • www.mql5.com
В данной ветке будем обсуждать разные способы решения тех, или иных задач, сравнивать производительность предложенных решений...
 

Can I have some details: why SocketTlsReadAvailable () returns error (5273 ERR_NETSOCKET_IO_ERROR) when Socket is connected (SocketIsConnected () returned true)?

Forum on Trading, Automated Trading Systems and Strategy Tests

Bugs, bugs, questions

Alain Verleyen, 2019.08.29 01:17

About mql SocketXXX functions () this message is mainly intended for Metaquotes developers: @Renat Fatkhullin, @Slava, @Ilyas

I am using the code below to control message reception over a secure connection.

int socket;
//+------------------------------------------------------------------+
//| void OnTimer()                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   string message;
   if(receive(message))
     {
      //--- ...     
     }
  }
//+------------------------------------------------------------------+
//| Call every X ms                                                  |
//+------------------------------------------------------------------+
bool receive(string &message)
  {
//--- ...
   char response[];
   message="";

   ResetLastError();
   uint len=SocketIsReadable(socket);
   if(len>1)
     {
      int read=SocketTlsReadAvailable(socket,response,len);

      //--- analyze the response 
      if(read>0)
        {
         //--- ...

         message=CharArrayToString(response,0,read);
         return(true);
        }
      else if(read==-1)
        {
         if(SocketIsConnected(socket))
           {
            printf("ERROR: %i, socket(%i) read: len=%i",_LastError,socket,len);
           }
         else
           {
            printf("ERROR: %i, socket(%i) not connected. len=%i",_LastError,socket,len);
            //--- ...            
           }
        }
     }
   else
     {
      if(_LastError!=0)
         printf("ERROR: %i (SocketIsReadable).",_LastError);
     }
//--- ...
   return(false);
  }

Most of the time it works correctly. However, occasionally I would get an error message although the socket is connected, and after some time (1 to 5/6 errors) it keeps working.

... data / messages received correctly

2019.08.29 00: 45: 43.019 XXXX (EURUSD, H1) ERROR: 5273, socket (1), read: len = 437
2019.08.29 00: 45: 43.237 XXXX (EURUSD, H1) ERROR: 5273, socket (1), read: len = 1242

... data / messages received correctly

Error 5273 is very common and does not help much. Is it possible to get more information about such errors?


Reason: