Errors, bugs, questions - page 1256

 
sanyooooook:

who knows, does OnChartEvent work in the tester?

It doesn't work for me.

It works in MT5 too.
 

I'm doing this, but it won't print anything:

//+------------------------------------------------------------------+
//|                                             CheckObjectClick.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "https:/"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
string           InpName="Button";            // Имя кнопки
ENUM_BASE_CORNER InpCorner=CORNER_LEFT_LOWER; // Угол графика для привязки
string           InpFont="Arial";             // Шрифт
int              InpFontSize=14;              // Размер шрифта
color            InpColor=clrBlack;           // Цвет текста
color            InpBackColor=C'236,233,216'; // Цвет фона
color            InpBorderColor=clrNONE;      // Цвет границы
bool             InpState=false;              // Нажата/Отжата
bool             InpBack=false;               // Объект на заднем плане
bool             InpSelection=false;          // Выделить для перемещений
bool             InpHidden=true;              // Скрыт в списке объектов
long             InpZOrder=0;                 // Приоритет на нажатие мышью

int OnInit()
  {
//---
   ButtonCreate(0,StringConcatenate(InpName,"LIMIT"),0,20,25,55,20,InpCorner,"LIMIT",InpFont,InpFontSize,
                InpColor,clrLime,InpBorderColor,InpState,InpBack,InpSelection,InpHidden,InpZOrder);
   ButtonCreate(0,StringConcatenate(InpName,"STOP"),0,80,25,60,20,InpCorner,"STOP",InpFont,InpFontSize,
                InpColor,clrRed,InpBorderColor,InpState,InpBack,InpSelection,InpHidden,InpZOrder);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   if(id==CHARTEVENT_OBJECT_CLICK)
   {
      string clickedChartObject=sparam;
      if(clickedChartObject=="ButtonLIMIT")
      {
        Print(1);
      }
      if(clickedChartObject=="ButtonSTOP")
      {
        Print(2);
      }
   }
   //int Click=EventChartCustom(id,CHARTEVENT_OBJECT_CLICK);
  }
  bool ButtonCreate(long              chart_ID=0,               // ID графика
                  string            name="Button",            // имя кнопки
                  int               sub_window=0,             // номер подокна
                  int               x=0,                      // координата по оси X
                  int               y=0,                      // координата по оси Y
                  int               width=50,                 // ширина кнопки
                  int               height=18,                // высота кнопки
                  ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // угол графика для привязки
                  string            text="Button",            // текст
                  string            font="Arial",             // шрифт
                  int               font_size=10,             // размер шрифта
                  color             clr=clrBlack,             // цвет текста
                  color             back_clr=C'236,233,216',  // цвет фона
                  color             border_clr=clrNONE,       // цвет границы
                  bool              state=false,              // нажата/отжата
                  bool              back=false,               // на заднем плане
                  bool              selection=false,          // выделить для перемещений
                  bool              hidden=true,              // скрыт в списке объектов
                  long              z_order=0)                // приоритет на нажатие мышью
  {
//--- сбросим значение ошибки
   ResetLastError();
//--- создадим кнопку
   if(ObjectFind(name)<0)
   {
     ObjectCreate(chart_ID,name,OBJ_BUTTON,sub_window,0,0);
   }
//--- установим координаты кнопки
   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
//--- установим размер кнопки
   ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);
   ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);
//--- установим угол графика, относительно которого будут определяться координаты точки
   //ObjectSet(name,OBJPROP_CORNER,corner);Print(GetLastError());
   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);

//--- установим текст
   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
//--- установим шрифт текста
   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
//--- установим размер шрифта
   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
//--- установим цвет текста
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- установим цвет фона
   ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);
//--- установим цвет границы
   ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,border_clr);
//--- отобразим на переднем (false) или заднем (true) плане
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- переведем кнопку в заданное состояние
   ObjectSetInteger(chart_ID,name,OBJPROP_STATE,state);
//--- включим (true) или отключим (false) режим перемещения кнопки мышью
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- скроем (true) или отобразим (false) имя графического объекта в списке объектов
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- установим приоритет на получение события нажатия мыши на графике
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- успешное выполнение
   return(true);
  }
 

or is there something wrong somewhere?

I've hardly ever worked with events in MT4 before, so I don't know.

ZZZ: Everything is fine on a normal chart.

 
sanyooooook:

or is there something wrong somewhere?

I've hardly ever worked with events in MT4 before, so I don't know.

ZS: On a normal chart all is fine prints.

Right, it doesn't. But it works. Try tracking the event with the chart.

 
svds75:

Hello Dear forum users. There is one situation that is not clear.

Actually the thing is that no way to make the function ChartOpen (), in the tester (visualizer), open a couple of graphs.

In normal mode, everything works, but in the tester, it constantly returns not zero as written in help, and the same number 16388.

I will be very grateful if someone tells me what's wrong. Test robot attached.

My friends, no one has faced with it? Or it is a recent bug? How do you test multivolutions with graphics then?
 
sanyooooook:

ZS: All the prints are fine on a normal chart.

Maybe you're looking in the wrong Journal... if you're in optimisation mode, the printers are switched off...

Show me the details of the tester settings

 
denkir:

You must be looking in the wrong Logbook... in fact, if you are in optimisation mode, the prints are switched off there...

Show me the details of the tester's settings.

I don't know where to look )

I don't even create objects during optimization. But I'm not in optimization mode.


 
I tried with a variable declared at global level, but its value doesn't change either.
 
sanyooooook:
I tried using a variable declared globally, but its value doesn't change either.
Where is the information that OnChartEvent() should work in the tester? Did I miss something? It still doesn't work for me. Neither in 4, nor in 5.
 
It works. I checked with my EA, it opens orders from the buttons. That's why it doesn't print, I wonder...
Reason: