Errors, bugs, questions - page 2392

 

Where can you see the implementation of the trading level via graphical objects

Need to be as close as possible to what the Terminal itself does.

 
fxsaber:

Where can you see the implementation of the trading level via graphical objects

Need as close as possible to what the Terminal itself does.

Horizontal line with DASHDOT style and description in OBJPROP_TEXT.

 
Andrey Khatimlianskii:

Horizontal line with DASHDOT style and description in OBJPROP_TEXT.

Thanks, didn't know about the text property.


It doesn't work. What am I doing wrong?

void OnStart()
{
  const string Name = __FUNCTION__;
  
  ObjectCreate(0, Name, OBJ_HLINE, 0, 0, SymbolInfoDouble(_Symbol, SYMBOL_BID));
  ObjectSetString(0, Name, OBJPROP_TEXT, "12345");
  ObjectSetString(0, Name, OBJPROP_LEVELTEXT, "12345");
}

I can't see the text.

 
fxsaber:

Thanks, didn't know about the text property.


It doesn't work. What am I doing wrong?

I can't see the text.

In the chart settings, turn on the display of text captions for graphical objects.
 
Artyom Trishkin:
In the chart settings, switch on the display of text captions for graphical objects.

Thank you!

 
fxsaber:

Thank you!

You can do it programmatically too.
 
Comments not related to this topic have been moved to "Questions from MQL4 MT4 MetaTrader 4 beginners".
 
Ilya Malev:

MQL5 ME 2006

Same code in MQL4 as it should be,"function 'f' must have a body"

Thanks for the message.

Corrected it, the correct error will be displayed.

 
Ilyas:

When will you fix the personal messages on the website?

1. The product update messages keep popping up (on the website and in the terminal). The same product. You read it and they come up again, read it again;

2. My own messages are highlighted (in the terminal). I know what I have written and I know who I have written it to. My own messages do not need to be highlighted as new!

 

Hi all.

Trying to combine several text labels into one long string. For some reason in absence of ticks (day off), and in usual mode functionObjectGetInteger(0,name,OBJPROP_XSIZE) returns 0 from time to time (not always) although "name" object definitely exists. In the tester, errors occur less frequently but they also occur.

The error code is 0 but the value is not acquired. Question for developers and experts. Why? What am I doing wrong or is this a bug?

2019.02.28 13:58:16.922 DBS_Bug3 (RTS-3.19,M4)  DBS_Bug3: GetLastX: Не удалось получить размер объекта dbs_inf_11! Код ошибки: 0. Операция выполнена успешно.

The code of a test Expert Advisor is below

//+------------------------------------------------------------------+
//|                                                     DBS_Bug3.mq5 |
//|                                            Copyright © 2019, DBS |
//+------------------------------------------------------------------+
#include "Include\Errors.mqh"
//+------------------------------------------------------------------+
//| Входные параметры эксперта                                       |
//+------------------------------------------------------------------+
sinput int     Renew_Interval=5;             //Интервал обновления, сек.
sinput string  iFontName="Tahoma";           //Название шрифта
sinput int     iFontSize=9;                  //Размер шрифта
sinput color   iColorBase=clrYellow;         //Основной цвет
sinput int     iText_X=300;                  //Смещение от левого края графика, пикс.
sinput int     iText_Y=5;                    //Смещение от верхнего края графика, пикс.
sinput string  iName_pref="dbs_inf_";        //Префикс имени объектов текста
//+------------------------------------------------------------------+
//| Глобальные переменные                                            |
//+------------------------------------------------------------------+
datetime LastCalculateTime=0;                //время последнего расчёта
//+------------------------------------------------------------------+
//| Обработчик события OnInit                                        | 
//+------------------------------------------------------------------+
int OnInit()
  {
   EventSetTimer(Renew_Interval);                                     //установка таймера
   ShowInfo();                                                        //отобразить информацию   
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Обработчик события Deinit                                        | 
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ObjectsDeleteAll(0,iName_pref);                                    //удаляем все свои объекты текста
   ChartRedraw();
  }
//+------------------------------------------------------------------+
//| Обработчик событий таймера                                       |
//+------------------------------------------------------------------+
void OnTimer()
  {
   if(SymbolInfoInteger(_Symbol,SYMBOL_TIME)>LastCalculateTime)       //проверка периода перерасчёта
      ShowInfo();                                                     //вывести информацию
  }
//+------------------------------------------------------------------+
//| Выводит на экран информацию про некоторые параметры эксперта     |
//+------------------------------------------------------------------+
void ShowInfo()
  {
   string t10="Прибыль: "+IntegerToString(MathRand())+" ";
   string t11="Убыток: "+IntegerToString(MathRand())+" ";
   string t12="Баланс: "+IntegerToString(MathRand())+" ";
   TextCreate(10,t10,iText_X,iText_Y);
   TextCreate(11,t11,GetLastX(10),iText_Y);
   TextCreate(12,t12,GetLastX(11),iText_Y);
   LastCalculateTime=TimeCurrent();                                   //запомним время последнего пересчёта
  }
//+------------------------------------------------------------------+
//| Функция получает значение координаты X конца заданного объекта   |
//+------------------------------------------------------------------+
int GetLastX(int a_idx)
  {
   string name=iName_pref+IntegerToString(a_idx);                    //имя объекта
   long x=ObjectGetInteger(0,name,OBJPROP_XDISTANCE);
   long size=ObjectGetInteger(0,name,OBJPROP_XSIZE);
   if(size==0)
      PrintFormat("%s: %s: Не удалось получить размер объекта %s! Код ошибки: %i. %s.",EXPERT_NAME,__FUNCTION__,name,_LastError,ErrorDescription(_LastError));
   return(int(x+size));
  }
//+------------------------------------------------------------------+ 
//| Создает объект "Текстовая метка"                                 | 
//+------------------------------------------------------------------+ 
bool TextCreate(const int    name_idx,                                //индекс имени объекта 
                const string text,                                    //текст
                const int    x=0,                                     //координата по оси X 
                const int    y=0,                                     //координата по оси Y
                const color  a_color=clrNONE)                         //цвет текста                
  {
   string name=iName_pref+IntegerToString(name_idx);                  //формируем имя объёкта
   if(!ObjectCreate(0,name,OBJ_LABEL,0,0,0)) // создадим объект "Текстовая метка" 
     {
      PrintFormat("%s: %s: Не удалось создать объект %s! Код ошибки: %i. %s.",EXPERT_NAME,__FUNCTION__,name,_LastError,ErrorDescription(_LastError));
      return(false);
     }
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);                      //установим координаты привязки объекта
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
   ObjectSetString(0,name,OBJPROP_TEXT,text);                         //установим текст 
   ObjectSetString(0,name,OBJPROP_TOOLTIP,text);
   ObjectSetString(0,name,OBJPROP_FONT,iFontName);                    //установим шрифт текста 
   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,iFontSize);               //установим размер шрифта
   color font_color=(a_color==clrNONE)?iColorBase:a_color;            //если цвет не задан - используем установленный в настройках
   ObjectSetInteger(0,name,OBJPROP_COLOR,font_color);                 //установим цвет объекта
   ObjectSetInteger(0,name,OBJPROP_BACK,false);                       //отобразим на переднем (false) или заднем (true) плане
   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);                 //включим (true) или отключим (false) режим перемещения объекта мышью 
   ObjectSetInteger(0,name,OBJPROP_SELECTED,false);                   //включим (true) или отключим (false) режим выделенности объекта
   ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);                      //скроем (true) или отобразим (false) имя графического объекта в списке объектов
   ChartRedraw();                                                     //обновим график   
   return(true);
  }
//+------------------------------------------------------------------+


P.S. By the way, none of the developers have answered my previous question

Files:
DBS_Bug3.mq5  13 kb
Reason: