Questions from Beginners MQL5 MT5 MetaTrader 5 - page 809

 
Hello!
Can you please tell me which kodobase topic has an example of an algorithm that draws numbers so that bar index numbers are displayed at the bottom and/or top of the window? As on the picture.
The point is that OBJ_TEXT is mapped to price and time and OBJ_LABEL to the window coordinates in pixels. But how to combine them?
 
Leo59:
Hello!
Can you please tell me which Kodobase theme has an example of an algorithm that draws the numbers so that the bottom and/or top of the window displays bar index numbers? As on the picture.
The point is that OBJ_TEXT is mapped to price and time and OBJ_LABEL to the window coordinates in pixels. But how to combine them?

You need to go to the price, and the price is the Higt or Low of the candlestick, then the objects will be in place

 
Vitaly Muzichenko:

You need to go to the price, and the price is the Higt or Low of the candlestick, then the objects will be in place

"at the bottom and/or top of the window displayed bar index numbers" and "specify Higt or Low candlestick" is not the "focus".

 
Leo59:

"the bottom and/or top of the window displayed bar index numbers" and "specify the Higt or Low of the candle" is not a "focus".

This?

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Примеры работы с графиком
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Примеры работы с графиком
  • www.mql5.com
В этом разделе представлены примеры для работы со свойствами графика. Для каждого свойства приведены одна или две законченные функции, которые позволяют задавать/получать значение этого свойства. Эти функции можно использовать в своих MQL5 программах как есть. На рисунке показана графическая панель для наглядной демонстрации того, как изменение...
 
Vitaly Muzichenko:

This?

I've been seeing this section for years. But that's all I've got brains for:
#property  indicator_chart_window

extern int History = 35;                                              // Сколько баров мы имеем ввиду
extern int Multiple = 5;                                              // Кратность отображаемой разметки

color    Color=0;
color    Color_multiple=Moccasin;                                     // Цвет индексов кратных "Multiple"
color    Color_between=MintCream;                                     // Цвет индексов промежуточных 
string   name="";
string   Text="";
int      Font_size=0;
int      Font_size_multiple=14;                                       // Размер шрифта индексов кратных "Multiple"
int      Font_size_between=8;                                         // Размер шрифта индексов промежуточных

bool     Back=true;                                                   //--- отобразим на переднем (false) или заднем (true) плане. Если (true), то подсветки дат не выводится
string   Font="Arial";                                                // Шрифт
double   Angle=270.0;                                                 // Угол наклона в градусах

int      Style=STYLE_DOT;                                             // Для всех - стиль пунктир
int      Width=1;                                                     // Толщина линии

//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
//+------------------------------------------------------------------+
//| Custom indicator initialization function                    F  1 | int init()
//+------------------------------------------------------------------+
int init()
   {
//    IndicatorShortName(IN + " (" + ")");                              // Короткое имя индикатора
    return(INIT_SUCCEEDED);                                           // Успешная инициализация приложения
   }

//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
//+------------------------------------------------------------------+
//| expert deinitialization function                             F 2 | int deinit()
//+------------------------------------------------------------------+
int deinit() // Время исполнения специальной функции deinit() ограничено периодом 2,5 секунды.
   {
    ObjectsDeleteAll(0, "label", 0);                                  // Идентификатор графика, префикс имени объекта, индекс окна
    return(0);                                                        // Выход из deinit()
   }

//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
//+------------------------------------------------------------------+
//| Custom indicator iteration function                         F  3 | int start()
//+------------------------------------------------------------------+
int start()
   {
    int i=0;
    int limit=Bars-IndicatorCounted()-1; 
    if(limit>1) limit=MathMin(Bars, History+(History==0)*Bars)-1;
    
    for(i=0; i<History; i++)
        {
         name = "label "+i;
         Text = DoubleToStr(i,0);
          
         if(MathMod(i, Multiple) == 0)                                     // MathMod() Возвращает вещественный остаток от деления двух чисел (i/Multiple).
             {
              Color = Color_multiple;
              Font_size = Font_size_multiple;

              if(ObjectFind(0, name)==-1)                                  // Если объект "name" не найден
                  {
                   ObjectCreate(0,name,OBJ_VLINE,0,Time[i],0);             // Создаем объект..
                   ObjectSetInteger(0,name,OBJPROP_STYLE,Style);           //--- установим стиль отображения линии
                   ObjectSetInteger(0,name,OBJPROP_WIDTH,Width);           //--- установим толщину линии
                   ObjectSetInteger(0,name,OBJPROP_COLOR,Color);           //--- установим цвет
                   ObjectSetString(0,name,OBJPROP_TEXT,Text);              //--- установим текст
                   ObjectSetString(0,name,OBJPROP_FONT,Font);              //--- установим шрифт текста
                   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,Font_size);    //--- установим размер шрифта
                   ObjectSetDouble(0,name,OBJPROP_ANGLE,Angle);            //--- установим угол наклона текста
                   // Для отображения текстового описания объекта необходимо включить галочку опции "Показывать описания объектов" в окне Графики->Свойства финансового инструмента (F8) > Общие.         
                   ObjectSetInteger(0,name,OBJPROP_BACK, Back);            //--- отобразим на переднем (false) или заднем (true) плане
                  }
               else                                                        // Если объект "name" найден
                  {
                   ObjectMove(0,name, 0, Time[i], 0);                     // Сообщение новых координат. 
                  }
             }
//         else
//             {
//              Color = Color_between;
//              Font_size = Font_size_between;
//
//              if(ObjectFind(0, name)==-1)                                  // Если объект "name" не найден
//                  {
//                   ObjectCreate(0,name,OBJ_VLINE,0,Time[i],0);             // Создаем объект..
//                   ObjectSetInteger(0,name,OBJPROP_STYLE,Style);           //--- установим стиль отображения линии
//                   ObjectSetInteger(0,name,OBJPROP_WIDTH,Width);           //--- установим толщину линии
//                   ObjectSetInteger(0,name,OBJPROP_COLOR,Color);           //--- установим цвет
//                   //ObjectSetString(0,name,OBJPROP_TEXT,Text);              //--- установим текст
//                   //ObjectSetString(0,name,OBJPROP_FONT,Font);              //--- установим шрифт текста
//                   //ObjectSetInteger(0,name,OBJPROP_FONTSIZE,Font_size);    //--- установим размер шрифта
//                   ObjectSetDouble(0,name,OBJPROP_ANGLE,Angle);            //--- установим угол наклона текста
//                   // Для отображения текстового описания объекта необходимо включить галочку опции "Показывать описания объектов" в окне Графики->Свойства финансового инструмента (F8) > Общие.         
//                   ObjectSetInteger(0,name,OBJPROP_BACK, Back);            //--- отобразим на переднем (false) или заднем (true) плане
//                  }
//               else                                                        // Если объект "name" найден
//                  {
//                   ObjectMove(0,name, 0, Time[i], 0);                     // Сообщение новых координат. 
//                  }
//             }
        }
    return(0);
   }

 
Leo59:
Hello!
Can you please tell me which Kodobase topic has an example of an algorithm that draws the numbers so that the bottom and/or top of the window displays the index numbers of the bars? As on the picture.
The point is that OBJ_TEXT is mapped to price and time and OBJ_LABEL to the window coordinates in pixels. But how to combine them?

Withthese functions ChartTimePriceToXY and ChartXYToTimePrice can be placed anywhere

 
Leo59:
Hello!
Can you please tell me which kodobase topic has an example of an algorithm that draws numbers so that bar index numbers are displayed at the bottom and/or top of the window? As on the picture.
The point is that OBJ_TEXT is mapped to price and time and OBJ_LABEL to the window coordinates in pixels. But how to combine them?

Why do I need numbers on a chart? The documentation has a ready solution to see the bar number

Документация по MQL5: Операции с массивами / ArraySetAsSeries
Документация по MQL5: Операции с массивами / ArraySetAsSeries
  • www.mql5.com
//| Custom indicator initialization function                         | //| Custom indicator iteration function                              |
 
Leo59:
I have seen this section for many years. But my brain is enough only for this:

An unobtrusive recommendation:

If-you're trying to master mql5, try to get rid of extern, int init(), int deinit() and int start().

replace them with full-fledged input, int OnInit(), void OnDeinit(const int reason) and void OnTick()

 

Greetings!


Can you tell me how to make an array of instu

I'm trying to do it like this:

input double Df_1 = 0.8;

input double Df_2 = 0.1;

input double Df_3 = 0.3;


const double Df[3] = {Df_1 ,Df_2 ,Df_3 };


but it generates an error :

'Df_1' - constant expression required

'Df_2' - constant expression required

'Df_3' - constant expression required

Referring to the array initialization string
 
Anttonnio:

Greetings!


Can you tell me how to make an array of instu

I'm trying to do it like this:

input double Df_1 = 0.8;

input double Df_2 = 0.1;

input double Df_3 = 0.3;


const double Df[3] = {Df_1 ,Df_2 ,Df_3 };


but it generates an error :

'Df_1' - constant expression required

'Df_2' - constant expression required

'Df_3' - constant expression required

Referring to the array initialization string

The array must be initialized with constants.

If you want to fill it with input parameters, first declare it and then itemize it.

Reason: