Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 459

 
HUNTERGOOD:

Good afternoon all. Dear programmers, please help me insert a line with the possibility to specify a sound file, for each Alert3.Lv1;2;3, to trigger a different sound that you specify.

Good afternoon all. Dear programmers, please help me to insert a string with the possibility to indicate a sound file for Alert3.Lv1;2;3 to trigger a different sound.

Good afternoon all. Dear programmers, please help me insert a string with the sound file for Alert3.Lv1;2;3 to trigger a different sound.

Start making, and you will get help.

Start making, and you will get help.

Start making and you will get help.

 

Help, the skates aren't slipping.

Trying to learn how to work with graphic panels and create my own.

I created 2 rectangles, 1 main rectangle, which coordinates all objects of the panel should be oriented to, when moving it.

I made such a condition in ChartEvent and now when I move the main rectangle, the second one moves only after 2-3 seconds, how to fix it?
I also tried CHARTEVENT_MOUSE_MOVE in the condition, same effect

input string ds;//Параметры заднего фона панели
input int x_offset_anchor=100;
input int y_offset_anchor=100;
int anchor_width=150;
int anchor_height=20;
int back_height=100;
input color anchor_color=clrBlue, back_color=clrAquamarine, clrBorder=clrAliceBlue;
input string ds2;//
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   RectLabelCreate(0,"Back_panel_anchor_point",0,x_offset_anchor,y_offset_anchor,anchor_width,anchor_height,anchor_color,BORDER_SUNKEN,CORNER_LEFT_UPPER,clrBorder,STYLE_SOLID,2,false,true,true,0);
   RectLabelCreate(0,"Back_panel",0,x_offset_anchor,y_offset_anchor+anchor_height,anchor_width,back_height,back_color,BORDER_SUNKEN,CORNER_LEFT_UPPER,clrBorder,STYLE_SOLID,1,false,false,true,0);
   
   
   
   ChartSetInteger(0,CHART_EVENT_MOUSE_MOVE,true);
//---
   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason){
   ObjectsDeleteAll(0,-1,-1);
}  
//+------------------------------------------------------------------+
//| 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 value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id == CHARTEVENT_OBJECT_DRAG && sparam == "Back_panel_anchor_point")
      {
         ObjectDelete(0,"Back_panel");
         RectLabelCreate(0,"Back_panel",0,ObjectGetInteger(0,"Back_panel_anchor_point", OBJPROP_XDISTANCE),ObjectGetInteger(0,"Back_panel_anchor_point", OBJPROP_YDISTANCE)+anchor_height,anchor_width,back_height,back_color,BORDER_SUNKEN,CORNER_LEFT_UPPER,clrBorder,STYLE_SOLID,1,false,false,true,0);
      }   
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+ 
//| Создает прямоугольную метку                                      | 
//+------------------------------------------------------------------+ 
bool RectLabelCreate(const long             chart_ID=0,               // ID графика 
                     const string           name="RectLabel",         // имя метки 
                     const int              sub_window=0,             // номер подокна 
                     const int              x=0,                      // координата по оси X 
                     const int              y=0,                      // координата по оси Y 
                     const int              width=50,                 // ширина 
                     const int              height=18,                // высота 
                     const color            back_clr=C'236,233,216',  // цвет фона 
                     const ENUM_BORDER_TYPE border=BORDER_SUNKEN,     // тип границы 
                     const ENUM_BASE_CORNER corner=CORNER_LEFT_UPPER, // угол графика для привязки 
                     const color            clr=clrRed,               // цвет плоской границы (Flat) 
                     const ENUM_LINE_STYLE  style=STYLE_SOLID,        // стиль плоской границы 
                     const int              line_width=1,             // толщина плоской границы 
                     const bool             back=false,               // на заднем плане 
                     const bool             selection=false,          // выделить для перемещений 
                     const bool             hidden=true,              // скрыт в списке объектов 
                     const long             z_order=0)                // приоритет на нажатие мышью 
  { 
//--- сбросим значение ошибки 
   ResetLastError(); 
//--- создадим прямоугольную метку 
   if(!ObjectCreate(chart_ID,name,OBJ_RECTANGLE_LABEL,sub_window,0,0)) 
     { 
      Print(__FUNCTION__, 
            ": не удалось создать прямоугольную метку! Код ошибки = ",GetLastError()); 
      return(false); 
     } 
//--- установим координаты метки 
   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); 
//--- установим цвет фона 
   ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr); 
//--- установим тип границы 
   ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_TYPE,border); 
//--- установим угол графика, относительно которого будут определяться координаты точки 
   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner); 
//--- установим цвет плоской рамки (в режиме Flat) 
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); 
//--- установим стиль линии плоской рамки 
   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style); 
//--- установим толщину плоской границы 
   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,line_width); 
//--- отобразим на переднем (false) или заднем (true) плане 
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); 
//--- включим (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); 
  } 
 
Roman Sharanov:

Help, the skates aren't slipping.

Trying to learn how to work with graphic panels and create my own.

I've created 2 rectangles, 1 main rectangle, which coordinates all panel objects should be oriented to when moving it.

I have made such a condition in ChartEvent, and now when I move the main rectangle, the second moves only after 2-3 seconds, how to do it?
also tried CHARTEVENT_MOUSE_MOVE in the condition, same effect

After creating an object and its moving I need to do ChartRedraw()

 
Vladislav Andruschenko:

After creating an object and moving it, you have to do ChartRedraw()

Yes, that's better. And so it's impossible to make it glide smoothly, right?

upd added condition to redraw only if this main rectangle is selected and it's ok now, thanks for the help!)

 

Repost from another thread. Maybe I'll shake someone up and get some help:


<The local experts remind me of my classmate (oh, how long ago it was) - he knew all the rules, all the formulas, but when to apply which, he could not immediately think, and went through almost everything, so that he never kept up with the allotted time. It's the same here: they know a lot, but they don't see the solution, they just work by "gut feeling". At the institute, we were taught to solve a problem without numbers and formulas, and only then will you clearly know which formulas to apply. Newcomers to MKL4 do not understand the subtleties of the language, and that is where they need help (not in the sense of "read a textbook"). But no one canshow you the pitfalls ofopening/closing positions. Maybe they do not know? So they let my question slide...>.

 
Greetings, help to write the current price into a file.
 
lil_lil:
Greetings, help to write the current price into a file.

Take a lookhere.

 
Artyom Trishkin:

Start doing and you will get help.

Start doing and you will get help.

Start doing, and you'll get help.

I appreciate your sarcasm, just not in a good way. What should I start doing? If I knew where to start, where to start and where to end, I probably wouldn't be interested in help from the more experienced sitters on this forum. I just think a person versed in this kind of activity, that is programming, it wouldn't be a problem for me to put some strings in some specific places, so that I could indicate a certain sound file in indicator. And you offer me to "start", with what basics should I start to master this great and inscrutable art of coding, so that I would know where correctly I need to put these same strings? Here's what I mean....

 
HUNTERGOOD:

I appreciated your sarcasm, just not on merit. What should I start doing? If I knew where to start, where to start and where to end, I probably would not have shown interest in help from more experienced members of this forum. I just think a person versed in this kind of activity, that is programming, it wouldn't be a problem for me to put some strings in some specific places, so that I could indicate a certain audio file in indicator. And you suggest me to "start", with what basics should I start to master this great and inscrutable art of coding, so that I would know where correctly I need to put these same strings? Here's what I mean....

The indicators don't work, only alert, only 1 sound.
 
Alexey Viktorov:

Seehere.

Thank you, the values there are from a file and one time and I have a task that stretches over time.

Record the current price and time at the beginning of each day for 30 minutes, every 120 seconds.

Do not overwrite previous entries.


Reason: