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

 
Ihor Herasko:

Show me how you get both. So far it seems as if we are talking about the same thing.

No, the values are different, I checked.

We throw this script onto the chart:

void OnStart()
  {
//---
   int chartHandle=ChartGetInteger(0,CHART_WINDOW_HANDLE);
   int idChart = ChartID(); 
   Alert("CHART_WINDOW_HANDLE = ",chartHandle," idChart=",idChart); 

  }

And we get:


 
khorosh:

No, the values are different, I checked.

Now I see what we are talking about.

chartHandle is a descriptor of the chart window assigned to the OS. You can use it to address the window from other threads via WinAPI.

idChart is an internal chart identifier assigned by the terminal itself. It can only be used for working from MQL.

 
Ihor Herasko:

It is now clear what we are talking about.

ChartHandle is a chart window descriptor assigned by the OS. You can use it to address the window from other threads via WinAPI.

idChart is an internal chart identifier assigned by the terminal itself. It can only be used to work from the MQL.

Got it, thanks!

 
Ihor Herasko:

It is now clear what we are talking about.

ChartHandle is a chart window descriptor assigned by the OS. You can use it to address the window from other threads via WinAPI.

idChart is an internal chart identifier assigned by the terminal itself. It can only be used from MQL.

So, if you need to address to the window of another open terminal, chartHandle should be used? And how to determine the chart identifier of the specified symbol from the indicator located on the chart of another symbol? For example, I need the indicator located on the EURJPY chart to create an object on the USDJPY chart. How can I define a USDJPY chart identifier?

 
khorosh:

It means that if you want to refer to the window of another open terminal, you should use chartHandle ? And how to determine the chart ID of the specified symbol from the indicator located on the chart of another symbol? For example, I need the indicator located on the EURJPY chart to create an object on the USDJPY chart. How can I define a USDJPY chart identifier?

In the ChartID() help I think there is an example of enumeration of all terminal charts.
 
Artyom Trishkin:
I think ChartID() help has an example of enumeration of all terminal charts.

No. It's empty. There's an example in the ChartNext help. Okay, got it. No further questions. Thank you.

 
khorosh:

So, if you want to access the window of another open terminal, chartHandle should be used?

When working only in MQL, chartHandle is not needed. Such a need may arise when connecting a DLL.

 
How can I define window index inObjectCreate() function?

boolObjectCreate(
longchart_id,// chart identifier
stringobject_name,// object name
ENUM_OBJECTobject_type,// object type
intsub_window,// window index
datetimetime1,// time of the first anchor point
doubleprice1,// price of the first anchor point
...
datetimetimeN=0,//time N-point binding
doublepriceN=0// price N-anchor point
);


 
khorosh:
How to define window index inObjectCreate() function?




It is not defined, it is set.

sub_window

[in] Subwindow number of the chart. 0 means the main window of the graph. The specified subwindow must exist, otherwise the function returns false.

 

WindowFind

WindowsTotal

Reason: