Errors, bugs, questions - page 1776

 

Compilation error

template<typename T>
int f( const T& ) { return sizeof( T ); }
class A {};
void OnStart()
{
        const A * const a = new A; //Error: 'T' - unexpected token
        f( a );
}
 

In the Metatrader 4 Help about the iGator() indicator

mode

[in]  Источник данных, идентификатор одной из линий индикатора. Mожет быть любой из следующих величин:

MODE_GATORJAW - синяя линия (линия челюсти аллигатора),
MODE_GATORTEETH - красная линия (линия зубов аллигатора),
MODE_GATORLIPS - зеленая линия (линия губ аллигатора).  


and below is an example

double diff=iGator(NULL,0,13,8,8,5,5,3,MODE_SMMA,PRICE_MEDIAN,MODE_UPPER,1);


Data source MODE_UPPER, I understand there is an error in the help

 

Compilation error (or rather no error message)

class A {
        A() { ::ArrayResize( i1, 1 ); }
        int i1[ ];
        int i2[1];
        void f1() const { i1[0] = 0; } //нет сообщения ошибки
        void f2() const { i2[0] = 0; } //Error: 'i2' - member of the constant object cannot be modified

};
 

I found two errors when handling mouse button click event.

1. handling mouse wheel click event in OnChartEvent(). The idea is that the function generates the event (id == CHARTEVENT_MOUSE_MOVE) when the left mouse button is clicked (with and without holding it), the right mouse button (with and without holding it), but if the wheel is clicked, the event will be generated only when holding it. I.e. if you just press the middle key and immediately release it, the event will not be generated!

2. After processing the left mouse button press (sparam == "1") the event sparam == "0" will be generated. After the right mouse button is clicked (sparam == "2"), for some reason the event sparam == "0" is not generated. Shouldn't all mouse buttons be handled the same way? I am silent about clicking on the wheel, because, as I said in point 1 - no event is generated when the wheel is clicked.

Check code:

#property indicator_chart_window
#property indicator_plots 0
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   ChartSetInteger(0,CHART_EVENT_MOUSE_MOVE,true);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {

   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Обработка события графика                                                                                                           |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
  {
   switch(id)
     {
      case CHARTEVENT_MOUSE_MOVE:
         FuncMove(lparam,dparam,sparam);
         break;
     }
  }
//+------------------------------------------------------------------+
//| Функция обработки события перемещения мыши                                                          |
//+------------------------------------------------------------------+
void FuncMove(const long lparam,// Х координата
              const double dparam,// Y координата
              const string sparam          // Строковое значение статуса кнопки
              )
  {
   Print(__FUNCTION__,": sparam = "+sparam);
  }
//+------------------------------------------------------------------+
//| Функция деинициализации индикатора                                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- Отписываемся от события передвижения мыши
   ChartSetInteger(0,CHART_EVENT_MOUSE_MOVE,false);
  }
//+------------------------------------------------------------------+
 
A100:

Compilation error (or rather no error message)

class A {
        A() { ::ArrayResize( i1, 1 ); }
        int i1[ ];
        int i2[1];
        void f1() const { i1[0] = 0; } //нет сообщения ошибки
        void f2() const { i2[0] = 0; } //Error: 'i2' - member of the constant object cannot be modified

};
in the f1 function, the state of the A object is not changed, the state of the dynamic array A::i1 is changed, the elements A::i1 do not belong to the A object
in the f2 function, the state of the A object changes, because the A::i2 array is not dynamic - all its elements belong to the A object
 
Dratuti. Question: How can I send a message to a user I haven't yet corresponded with on mobile browsers (android, apple)? I looked from several different devices - nowhere is there a button "send a message", as well as "add to others". The user's page looks something like this, there are no buttons:
 

Compilation error

class A {};
class B {
        int A() { return 0; }
        void f( int ) {}
        void g() { f(A()); } //Error: 'A' - invalid cast operation
};
 
Andrey Sokolov:
Dratuti. Question: how do I send a message to a user I haven't yet corresponded with on mobile browsers (android, apple)? I've looked from several different devices - nowhere is there a button "send a message", as well as "add to others". The user's page looks something like this, no buttons:

I've been saying that for a long time. so far they haven't said anything.

 
Alexey Kozitsyn:

Found two errors in mouse button event handling.


Let's check.
 
Alexander:
Check.

Thank you, please check the number of the first visible bar on the chart: ChartGetInteger( 0, CHART_FIRST_VISIBLE_BAR );

The point is that if you disable chart scrolling and monitor the last visible bar, then at the moment of a new candle its number changes for some reason, although the chart does not move! The TF is M1 in order to be able to check faster. Start from the indicator:

#property indicator_chart_window
#property indicator_plots 0
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
   {
    //--- Подписываемся на событие движения мыши
         ChartSetInteger( 0, CHART_EVENT_MOUSE_MOVE, true );
         //---
    return(INIT_SUCCEEDED);
   }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
   {

    return(rates_total);
   }
//+------------------------------------------------------------------+
//| Обработка события графика                                        |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long& lparam,const double& dparam,const string& sparam)
   {
    switch( id )        
        {
         case CHARTEVENT_MOUSE_MOVE:
                 Print( __FUNCTION__," "+TimeToString( TimeCurrent(), TIME_DATE|TIME_SECONDS )+": sparam = "+sparam+", ",(int)ChartGetInteger( 0, CHART_FIRST_VISIBLE_BAR ));
                 break;
        }
   }
Reason: