Errors, bugs, questions - page 2040

 

Doesn't work in the indicator subwindow, what am I doing wrong?

  datetime dt =0; 
  double price =0; 
  int window= ChartWindowFind();
  ChartXYToTimePrice(0,5,34,window,dt,price);
  PrintFormat("Window=%d  =>  time=%s  Price=%G",window,TimeToString(dt),price);

2017.10.15 05:35:36.060	i-Stp EURCHF,M30: Window=0  =>  _Time=2017.09.29 22:00  _Price=0.904348
  datetime dt =0; 
  double price =0; 
  int window= ChartWindowFind();
// ChartXYToTimePrice(0,5,34,window,dt,price);
  PrintFormat("Window=%d  =>  _Time=%s  _Price=%G",window,TimeToString(dt),price); 

2017.10.15 05:37:13.997	i-Stp EURCHF,M30: Window=1  =>  _Time=1970.01.01 00:00  _Price=0
 
Yury Kulikov:

MouseMove(x, y, key) parameters are used. The cursor position and mouse click are determined, the main line is moved by mql, not by the capabilities of the terminal interface, i.e. the program monitors the position of the cursor relative to the line, not the line movement. Simultaneous movement of lines is ensured by synchronous change of coordinates of the main and dependent lines.

Strangely, I don't use mouse coordinates at all, just responding to id == CHARTEVENT_MOUSE_MOVE. And everything works fine, which is actually logical.

You don't need custom DND for smoothness. If you make a custom DND then you should also make custom objects via kanvas. There can't be any lag, because the object is always the same.

 
Vitaly Muzichenko:

Doesn't work in the indicator subwindow, what am I doing wrong?

what was expected and what exactly is not working?
 
Kirill Belousov:
but what was expected and what exactly isn't working?

Expected to convert coordinates in a sub-window, and get a price.

Works in the main window, it does not work in subwindows, as you can see from the prints.

Also, the function substitutes the subwindow number with "0", i.e. with the main one:

Преобразует координаты  X и Y графика в значения время и цена.
bool  ChartXYToTimePrice(
   long           chart_id,     // идентификатор графика
   int            x,            // координата X на графике
   int            y,            // координата Y на графике
   int&           sub_window,   // номер подокна
   datetime&      time,         // время на графике
   double&        price         // цена на графике
   );
 

Compilation error

int f() { return 1; }
void OnStart() export
{
        for   ( int i = f();           ;) {} //(1) нормально
        for   (            ;int i = f();) {} //(2) 'i' - unexpected token
        while (             int i = f() ) {} //(3) 'i' - unexpected token
}
 
Vitaly Muzichenko:

Expected to convert coordinates in a sub-window, and get a price.

Works in the main window, it does not work in subwindows, as you can see from the prints.

Also, the function substitutes the subwindow number with "0", i.e. with the main one:

From the function help: X and Y - coordinates are counted from the upper left corner of the main chart window.

x=5, y=34 also refers to the main window, therefore output window=0.

Try increasing Y by the height of the main window to "end up" in a different window

 
A100:

Compilation error

is it acceptable to declare and assign inside while(...) instead of checking for a condition?
 
Kirill Belousov:

From the function help: X and Y are coordinates referenced from the top left corner of the main graph window.

x=5, y=34 also refers to the main window, so the output is window=0.

Try increasing Y by the height of the main window to "end up" in another window

This is not the answer at all, nor is it the output.

We specify the subwindow number, and it could be 3 or 4, then how do we specify the coordinates?

There is a clear error in the function.

 
Vitaly Muzichenko:

This is not the answer at all, nor is it the solution.

We specify the subwindow number, and it could be 3 or 4, then how do we specify the coordinates?

There is a clear error in the function.

We do not specify the subwindow number, but the function tells us (this is an output parameter, not an input parameter) - in which subwindow of the chart with the specified ID is the price chart and tells us what price and time correspond to the specified X,Y coordinates on that chart.
 
Kirill Belousov:
Is it acceptable to declare and assign inside while(...) instead of checking the condition?

Let the developers check. C++ compiles, although line (2) [but not (3)] may cause an error in obsolete compilers

Reason: