Questions from a "dummy" - page 9

 
stringo:

That's not the point I was making.

It says tester agent logs, it means tester agent logs.

Well first, for the latecomers, you need to specify where and what (preferably in pictures)...
 

Is it possible to make the object move by dragging smoothly horizontally or vertically?

I want to make a kind of scroll for a graph.

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов - Документация по MQL5
 
kPVT:

Is it possible to make an object move by dragging smoothly The chart object can be made to move along a horizontal or vertical line?

I want to make a kind of scroll for the graph.

Found a script, tweaked it a bit:

#import "user32.dll"
bool      GetCursorPos(int &Pos[]);
bool      GetWindowRect(int hWnd,int &Pos[]);
#import
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   int p[2];
   int rect[4];
   int hwnd=ChartGetInteger(ChartID(),CHART_WINDOW_HANDLE);
   while(!IsStopped())
     {
      GetWindowRect(hwnd,rect);
      GetCursorPos(p);
      int X=p[0]-rect[0];
      int Y=p[1]-rect[1];
      string c="Глобальные координаты мыши x= "+p[0]+" y= "+p[1]+"\n"+
               "Координаты мыши в окне котировок x= "+X+" y= "+Y;
      Comment(c);
      Sleep(100);
     }
  }
//+------------------------------------------------------------------+

I'll try to use user32.dll to get mouse coordinates to make scrolling smooth, should work.

In general it would be nice to have built in Chart object navigation.

 
Have you seen the example in the Angle section?
 
Rosh:
Did you look at the example in the Binding Angle section ?

Thanks, already found and deleted the message, but you were quicker:)

I have another question, the EA works on OnTimer but the window is updated only with the next tick, can this be dealt with?

 
Olegts:

Thanks, already found and deleted the message, but you were quicker:)

I have another question, the EA works on OnTimer, but the window is updated only with the next tick, can this be dealt with?

The window in the sense of objects on the chart?

ChartRedraw - forcibly redraw the chart (most likely this should help).

Документация по MQL5: Операции с графиками / ChartRedraw
Документация по MQL5: Операции с графиками / ChartRedraw
  • www.mql5.com
Операции с графиками / ChartRedraw - Документация по MQL5
 
Interesting:

Window in the sense of objects on the graph?

ChartRedraw - forcibly redraws the graph (this should probably help).

I put ChartRedraw(0); , the window is exactly zero and the only one, it does not help, the objects are updated only after the next tick, although Print() shows the change of data once per second EventSetTimer(1)
 
Olegts:
I put ChartRedraw(0); the window is zero and the only one, it doesn't help, objects are updated only after the next tick, though Print() shows the data change once per second EventSetTimer(1)

Then, at the very least, more information is needed.

What are the objects? Who creates them and how (for example, objects can be created/changed by an owl or by an indicator)?

And the situation in general is described very vaguely.

 
Interesting:

Then, at the very least, more information is needed.

What are the objects? Who creates them and how (for example, objects can be created/modified by owl, or by turkeys)?

And the overall situation is very vaguely described.

//+------------------------------------------------------------------+
//|                                                    testClass.mq5 |
//|                        Copyright 2011, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"

//--- input parameters

input int Timer=1;


int Val=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(Timer);
   int height=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0);
   int width=ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0);
   int step=0;
   step=step+30; CreateLabel(0,"EUR",CORNER_LEFT_UPPER,"",50,step);
   step=step+30; CreateLabel(0,"GBP",CORNER_LEFT_UPPER,"",50,step);
   
   
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
   ObjectDelete(0,"EUR");
   ObjectDelete(0,"GBP");
  
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
//void OnTick()
//  {
//---
//   
//  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   Val=Val+1;
   int EUR0=Val,EUR1=Val;
   
   int GBP0=Val,GBP1=Val;

     
   ObjectSetString(0,"EUR",OBJPROP_TEXT,"EUR: "+IntegerToString(EUR0)+" | "+IntegerToString(EUR1));
   ObjectSetString(0,"GBP",OBJPROP_TEXT,"GBP: "+IntegerToString(GBP0)+" | "+IntegerToString(GBP1));

   ChartRedraw(0);
//---
  }
//+------------------------------------------------------------------+

void CreateLabel(long   chart_id,
                 string name,
                 int    chart_corner,
                 string text_label,
                 int    x_ord,
                 int    y_ord)
  {
//---
   ObjectCreate(chart_id,name,OBJ_LABEL,0,0,0);
   ResetLastError();
   if(!ObjectSetInteger(chart_id,name,OBJPROP_CORNER,chart_corner))
      Print("Не удалось установить угол привязки для объекта ",
            name,", ошибка ",GetLastError());
   ObjectSetInteger(chart_id,name,OBJPROP_XDISTANCE,x_ord);
   ObjectSetInteger(chart_id,name,OBJPROP_YDISTANCE,y_ord);
   ObjectSetString(chart_id,name,OBJPROP_TEXT,text_label);
   }
 
Olegts:
Everything updates normally, the values change every second.