Ошибки, баги, вопросы - страница 2314

SuhanovDM94:

Но, ведь, обработчик нажатия же есть? Значит, и событие нажатия должно быть.

Вы ничего не путаете? Есть событие CHARTEVENT_CLICK — щелчок мыши на графике; но не нажатие...

Alexey Viktorov:

Вы ничего не путаете? Есть событие CHARTEVENT_CLICK — щелчок мыши на графике; но не нажатие...

Есть, всё верно. Просто у класса CButton есть два обработчика внутренних событий: OnMouseDown() и OnMouseUp(). Вот я и подумал, может, существуют и соответствующие события?

SuhanovDM94:

Есть, всё верно. Просто у класса CButton есть два обработчика внутренних событий: OnMouseDown() и OnMouseUp(). Вот я и подумал, может, существуют и соответствующие события?

Я не смотрел СБ, но видимо там одно нажатие OBJPROP_STATE == true, другое OBJPROP_STATE == false. А может я не прав.

всем привет  помогите . почему график в низ идет .в конце оптимизации  вот такие графики это нормально или нет 
Файлы:
Крашатся оба редактора МТ4 и МТ5 при наведении мыши на слово "func" в строчке "int i = func( 0, 1 );" и выборе опции "Перейти к определению" (или при нажатии Alt+G)

MQL4 build 1910
MQL5 build 1931

template<typename type>  
type func( type a, type b = 1 ){ return ( 0 ); }

int i = func( 0, 1 );

void OnStart(){ }  

Файлы:
altg.jpg  57 kb

Forum on trading, automated trading systems and testing trading strategies

MQL equivalent to Python's None type?

nicholi shen, 2018.10.28 21:52

Not in MQL, not anymore anyways. It's actually twice as slow passing as reference in debugging, and close enough to the same when compiled normally that it really doesn't matter. Try for yourself. 

#define ITERATIONS 1000000

void OnStart()
{
   {
      ulong time = GetMicrosecondCount();
      ulong sum = 0;
      for(int i=0; i<ITERATIONS; i++){
         string r = string(rand());
         sum += by_ref(r);
      }
      time = GetMicrosecondCount() - time;
      printf("%s took %.3f milliseconds: sum=%dll", "by_ref", time/1000.0, sum);
   }{
      ulong time = GetMicrosecondCount();
      ulong sum = 0;
      for(int i=0; i<ITERATIONS; i++)
         sum += by_val(string(rand()));
      time = GetMicrosecondCount() - time;
      printf("%s took %.3f milliseconds: sum=%dll", "by_val", time/1000.0, sum);
   }
}
//+------------------------------------------------------------------+

int by_ref(string &var){ return int(var) % 100; }
int by_val(string  var){ return int(var) % 100; }

Почему by_ref работает медленнее by_val?

fxsaber:

Почему by_ref работает медленнее by_val?

Откуда это следует?

Если код одинаковый

//Test.mqh
        int by_ref(string& var) { return int(var) % 100; }
        int by_val(string  var) { return int(var) % 100; }
//Test.mq5
#include "Test.mqh"
#define ITERATIONS 1000000
#define MACRO( X ) \
        { \
                ulong time = GetMicrosecondCount(); \
                for(int i=0; i<ITERATIONS; i++) \
                { \
                        string r = string( rand ); \
                        sum_##X += by_##X(r); \
                } \
                time_##X = GetMicrosecondCount() - time; \
        }
void OnStart()
{
        for ( int i = 0; i < 10; i++ )
                OnStart2( rand());
}
void OnStart2( int rand )
{
        long time_ref, sum_ref = 0;
        long time_val, sum_val = 0;
        MACRO( ref )
        MACRO( val )
        printf( "%+10.3f:%d", (time_ref-time_val)/1000.0, sum_ref-sum_val );
}

то и Pезультат (разница времени выполнения):

    +12.221:0
     +5.099:0
     +0.149:0
    -13.729:0
    +14.531:0
    -27.429:0
    +26.405:0
     -0.839:0
     +5.400:0
     -4.882:0

чередуется (+\-) в незначительных пределах

A100:

Откуда это следует?

#define ITERATIONS 1000000

void OnStart()
{
   string Str = "1";
   
   for (int i = 0; i < 10; i++)
     Str += Str;
   
   for (int j = 0; j < 5; j++)
   {
     {
        ulong time = GetMicrosecondCount();
        ulong sum = 0;
        for(int i=0; i<ITERATIONS; i++){
           string r = string(rand()) + Str;
           sum += by_ref(r);
        }
        time = GetMicrosecondCount() - time;
        printf("%s took %.3f milliseconds: sum=%dll", "by_ref", time/1000.0, sum);
     }{
        ulong time = GetMicrosecondCount();
        ulong sum = 0;
        for(int i=0; i<ITERATIONS; i++)
           sum += by_val(string(rand()) + Str);
        time = GetMicrosecondCount() - time;
        printf("%s took %.3f milliseconds: sum=%dll", "by_val", time/1000.0, sum);
     }
     
     Print("");
   }
}
//+------------------------------------------------------------------+

int by_ref(string &var){ return int(var) % 100; }
int by_val(string  var){ return int(var) % 100; }


by_ref took 15119.806 milliseconds: sum=-1000000ll
by_val took 13872.479 milliseconds: sum=-1000000ll

by_ref took 14433.781 milliseconds: sum=-1000000ll
by_val took 13817.533 milliseconds: sum=-1000000ll

by_ref took 13889.424 milliseconds: sum=-1000000ll
by_val took 14135.603 milliseconds: sum=-1000000ll

by_ref took 16047.643 milliseconds: sum=-1000000ll
by_val took 14494.432 milliseconds: sum=-1000000ll

by_ref took 15542.276 milliseconds: sum=-1000000ll
by_val took 13843.121 milliseconds: sum=-1000000ll
Nikolai Semko:

Захотел поставить оценку в КБ и не получилось. И судя по тому, что последние публикации вовсе не имееют оценок, то похоже, что эта проблема не только у меня.

Да, не работает.

fxsaber:
У меня в циклах ref и val одинаковый код (сравнение более менее корректное), а у Вас разный