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

 
Artyom Trishkin:

The best recommendation here is to read the help more often.

It specifies the properties that can be retrieved/set for the graph.

In particular - scrolling the graph with the left mouse button.

This is the place in the documentation that I have read.

When CHART_EVENT_MOUSE_MOVE = 1, the graph receives mouse movement messages, but when CHART_EVENT_MOUSE_MOVE = 0, it does not. This is understandable.
But it is not relevant to my question... No matter what value is set for CHART_EVENT_MOUSE_MOVE, I always have a possibility to "move" the chart with AUTOSCROLL turned off
"shift" the graph in the window to the past (in terms of time) simply by pressing the left mouse button and without releasing the button move the mouse to the right.
This shifts the graph in the window ALWAYS.
However, if I press Ctrl+F (to call Crosshair) - then when I press the left mouse button, hold it down and move the graph, I will see the beam
the tooltip will show data on the mouse movement and the price of the level where the mouse pointer is located.
And most importantly - the graph itself at that moment will not move in the window.

That's how to achieve this effect without enabling Crosshair, that's what I'm asking...

P.S. I can take a video of the screen and show you how it looks.

 
Maksims Ignatovs:

I have read this place in the documentation.

When CHART_EVENT_MOUSE_MOVE = 1, the chart receives messages about mouse moving, but if CHART_EVENT_MOUSE_MOVE = 0, it does not. This is understandable.
But it is not relevant to my question... No matter what value is set for CHART_EVENT_MOUSE_MOVE, I always have a possibility to "move" the chart with AUTOSCROLL turned off
"shift" the graph in the window to the past (in terms of time) simply by pressing the left mouse button and without releasing the button move the mouse to the right.
This shifts the graph in the window ALWAYS.
However, if I press Ctrl+F (to call Crosshair) - then when I press the left mouse button, hold it down and move the graph, I will see the beam
the tooltip will show data on mouse movement and the price of the level where the mouse pointer is located.
And most importantly - the graph itself at that moment will not move in the window.

That's how to achieve this effect without switching Crosshair on, that's what I'm asking...

P.S. I can take a video of the screen and show you what it looks like.

Didn't I answer that?
If you shift something on the chart with the mouse, you prohibit shifting the chart at this moment. As soon as you release the mouse button, you allow the graph to shift.

 

Can the fields of a structure be accessed using indexing, i.e. as a one-dimensional array? Is it possible to create an array of structure fields?

So the idea is this. There is a structure

struct MyStruct {int qw;double qe;}; MyStruct qr; 
//пример по сложнее
struct MyStruct1{int qw[5];double qe[5];}; MyStruct1 qr1;

Then, when passing any structure to a function, we have to address each element by name separately.

qr.qw qr.q51e, etc. Of course, you won't be able to put it into a loop and process it with a single thread. I want to create an array of fields that will store these items as follows

Massiv[2];
//Massiv[0] отвечает за эту запись qr.qw
//Massiv[1] отвечает за эту запись qr.qе

As a result, we can address these items through indexing and, of course, the second structure can be put into a loop and handle qw qe through the loop.

Is it possible to do so, I've seen such entries on the Internet some time ago, but maybe I've misunderstood something because I've lost the site? Maybe typedef enum union macros can help?

 
Artyom Trishkin:
Didn't I answer that?
If you move something on the graph with the mouse, you disable graph shifting at that moment. As soon as you release the mouse button, you allow the graph to shift.

I don't move anything on the chart. If I setCHART_EVENT_MOUSE_MOVE = 0 it doesn't help - the chart can still be moved.
I don't knowhow to disable ChartNavigate processing for the chart. I didn't find it in documentation either.
At the same time "crosshair" somehow copes with this case. That's why I'm asking - how?
You answer me - just set the correct value forCHART_EVENT_MOUSE_MOVE. I tried it - it does not help.
With any value of
CHART_EVENT_MOUSE_MOVE, you can still move the graph with the mouse back and forth in time by simply holding down the left mouse button on the graph and moving the mouse.
At the same time, depending on the direction of moving the mouse horizontally, the chart will shift in the window If I move the mouse to the right, the chart will shift to the left (to the past history),
and if I move the mouse to the left, the chart will shift to the future until the current bar appears. After that, an attempt to shift it to the left with the mouse will not work. But this is understandable.
If I
move the chart in the window to some date in the past using ChartNavigate, what should I do to ensure that under no circumstances (no manipulations with clicks and mouse movements on the chart), the part of the chart which I see will not be shifted? What do I have to do?


 
Maksims Ignatovs:

I don't move anything on the chart. If I set CHART_EVENT_MOUSE_MOVE = 0 it doesn't help - the chart can still be moved.
I don't know how to disable ChartNavigate processing for the chart. I haven't found it in documentation either.


ChartSetInteger(0, CHART_MOUSE_SCROLL, 0); // Выключим прокрутку графика
 
Good afternoon, please fix the indicator, you need to display the server time through the button, provided that the button in its original position should show
This is what I did NOT get:
#property copyright "Copyright 2014, ForexDE"
#property link      ""
#property version   "1.00"
#property strict
#property indicator_chart_window

string s1="";

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{

   PutButton("B",50,50,"KNOPKA");
   
   if(DayOfWeek()==1)
      s1="Понедельник  /  ";
   if(DayOfWeek()==2)
      s1="Вторник  /  ";
   if(DayOfWeek()==3)
      s1="Среда  /  ";
   if(DayOfWeek()==4)
      s1="Четверг  /  ";
   if(DayOfWeek()==5)
      s1="Пятница  /  ";
   if(DayOfWeek()==6)
      s1="Суббота  /  ";
   if(DayOfWeek()==0)
      s1="Воскресенье  /  ";

   ObjectCreate("WeekDay1",OBJ_LABEL,0,0,0);          
   ObjectSet("WeekDay1",OBJPROP_CORNER,CORNER_RIGHT_LOWER);
   ObjectSet("WeekDay1",OBJPROP_XDISTANCE,5);
   ObjectSet("WeekDay1",OBJPROP_YDISTANCE,2);
   ObjectSet("WeekDay1",OBJPROP_SELECTABLE,false);
   ObjectSet("WeekDay1",OBJPROP_HIDDEN,true);
   ObjectSet("WeekDay1",OBJPROP_ANCHOR,ANCHOR_RIGHT_LOWER);
   ObjectSet("WeekDay1",OBJPROP_COLOR,Black);
   ObjectSet("WeekDay1",OBJPROP_SELECTABLE,false);
   ObjectSet("WeekDay1",OBJPROP_SELECTED,false);
   ObjectSetText("WeekDay1",s1+TimeToString(CurTime(),TIME_DATE)+"  -  " +TimeToString(CurTime(),TIME_SECONDS),13,"Arial",Red);
   
   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[])
 {
 
   if(DayOfWeek()==1)
      s1="Понедельник  /  ";
   if(DayOfWeek()==2)
      s1="Вторник  /  ";
   if(DayOfWeek()==3)
      s1="Среда  /  ";
   if(DayOfWeek()==4)
      s1="Четверг  /  ";
   if(DayOfWeek()==5)
      s1="Пятница  /  ";
   if(DayOfWeek()==6)
      s1="Суббота  /  ";
   if(DayOfWeek()==0)
      s1="Воскресенье  /  ";
 
   ObjectSetText("WeekDay1",s1+TimeToString(CurTime(),TIME_DATE)+"  -  " +TimeToString(CurTime(),TIME_SECONDS),13,"Arial",Red);

  return(rates_total);
 }/*******************************************************************/

/********************************************************************/
void OnChartEvent(const int id,         // идентификатор события
                  const long& lparam,   // параметр события типа long
                  const double& dparam, // параметр события типа double
                  const string& sparam  // параметр события типа string
                 )
 {

  if(id == CHARTEVENT_CLICK)
   {
   
         if(!ObjectGetInteger(0,"B",OBJPROP_STATE,false))
           {
   ObjectSet("WeekDay1",OBJPROP_XDISTANCE,7000); // скрываю 
           }
         else
           {
   ObjectSet("WeekDay1",OBJPROP_XDISTANCE,5);    // показываю обратно
           }
   


   }
   
 }
/*******************************************************************/
void PutButton(string name,int x,int y,string text)
  {
   ObjectCreate(0,name,OBJ_BUTTON,0,0,0);
//--- установим координаты кнопки
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
//--- установим размер кнопки
   ObjectSetInteger(0,name,OBJPROP_XSIZE,80);
   ObjectSetInteger(0,name,OBJPROP_YSIZE,30);
//--- установим угол графика, относительно которого будут определяться координаты точки
   ObjectSetInteger(0,name,OBJPROP_CORNER,2);
//--- установим текст
   ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- установим шрифт текста
   ObjectSetString(0,name,OBJPROP_FONT,"Arial");
//--- установим размер шрифта
   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,12);
//--- установим цвет текста
   ObjectSetInteger(0,name,OBJPROP_COLOR,Red);
//--- установим цвет фона
   ObjectSetInteger(0,name,OBJPROP_BGCOLOR,White);
//--- установим цвет границы
   ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,Blue);
  }
 

vebster005:
Добрый день, исправьте пожалуйста индикатор, нужно вывести серверное время через кнопку, при условии что кнопка в исходном положении должна показывать
Вот что у меня НЕ получилось:

what exactly did not work ? i.e. in your own words what you wanted to do...

a button is made, when you press it, it runs off the screen (if it's not wide)

why are you not happy with the result ?

 
Maxim Kuznetsov:

What exactly have you failed to do? i.e. in your own words what you wanted to do...

a button is made, when you press it, it runs off the screen (if it's not wide)

What is wrong with the result?

the result is that when you clicked on the button the time was hidden and then reappeared because it is updated because of the fact that in the calculator

 
Maxim Kuznetsov:

What exactly have you failed to do? i.e. in your own words what you wanted to do...

a button is made, when you press it, it runs off the screen (if it's not wide)

why are you not happy with the result ?

Could you make it work for seconds and everything else, like in the terminal, and you can disable the button
because when I disable the button (remove it from the screen) the time reappears

 
vebster005:

Could you get the result that seconds and everything else works, like in the terminal, and you can disable the button
because when I disable the button (remove it from the screen) the time reappears

There are a lot of people here who can achieve almost any results.

It is important that you yourself try to achieve them, rather than begging others to do it for you. They are always willing to help, but to help, not to do it for you.

Reason: