Download MetaTrader 5

Window handle

To add comments, please log in or register
Patrick Chalindar
241
Patrick Chalindar  

‌Hello,

I have a question about chartGetInteger:

Normaly and If I understand well how this function works, I can recover the CHART_WINDOW_HANDLE like this:

ChartGetInteger(0,CHART_WINDOW_HANDLE) and it works if chart id is 0, but if I try to recover the chart ID of chart B from chart A, it doesn't work, function return 0, and error is 4122, chart didn't find.

I know I can recover this if I use WindowHandle(), but in this case, if I have 2 similars charts with same symbol and same period, how can I do the différence?

Can somobedy help me please?

Thanks so much in advance.‌

ChartGetInteger - Chart Operations - MQL4 Reference
ChartGetInteger - Chart Operations - MQL4 Reference
  • docs.mql4.com
ChartGetInteger - Chart Operations - MQL4 Reference
whroeder1
17061
whroeder1  
neo-13: t if I try to recover the chart ID of chart B from chart A, it doesn't work,
You posted that code where? There are no mind readers here.
Patrick Chalindar
241
Patrick Chalindar  
whroeder1:
You posted that code where? There are no mind readers here.
What diffrence there is if write this code in init, just for test or in a function call by onTick?
Fernando Carreiro
3952
Fernando Carreiro  
neo-13: What diffrence there is if write this code in init, just for test or in a function call by onTick?

He did not question if it is in "OnInit()" or "OnTick()" (although that can be important to the fact), but he questions why you did not provide your code sample so as to evaluate if you are doing it correctly or not and if there are other factors involved.

Hence, his statement "we are not mind readers" and can therefore not know what you are doing in your code unless you show it to us! Otherwise all we can do is just guess!

Patrick Chalindar
241
Patrick Chalindar  
Fernando Carreiro:

He did not question if it is in "OnInit()" or "OnTick()" (although that can be important to the fact), but he questions why you did not provide your code sample so as to evaluate if you are doing it correctly or not and if there are other factors involved.

Hence, his statement "we are not mind readers" and can therefore not know what you are doing in your code unless you show it to us! Otherwise all we can do is just guess!

Thanks for your explanation,

but I didn't take his answer bad, but in the same time, I ask just a simple answer because for me a function, if you put right parameters must works fine no?

And I try, in first time to use it, witout any code, just from Init(), and in this case no possibility for interference with any code:

just ‌as it is in documentation ChartGetInteger(0,CHART_WINDOW_HANDLE) and I repeat, if I write 0 as chartID, and I call the function, it works fine, but if I call the function from chart A for recover the chart B window Handle, doesn't work.

May be the problem is that the idchart I write in the second case is a long and not an int‌. I revover the idchart B with ChartFirst(), and this function return a long.

Do you have a solution for transform a long into an int or recover the idchart in int and not long.

Thanks‌

ChartGetInteger - Chart Operations - MQL4 Reference
ChartGetInteger - Chart Operations - MQL4 Reference
  • docs.mql4.com
ChartGetInteger - Chart Operations - MQL4 Reference
whroeder1
17061
whroeder1  
neo-13: if you put right parameters must works fine no?
  1. I just answered that question in another post, the call was correct but it global variable initialization, not in OnTick therefor had no value.
  2. How do we know that your call (for chart B) is correct? Post the code, and stop wasting our time.
Fernando Carreiro
3952
Fernando Carreiro  
neo-13:

Thanks for your explanation,

but I didn't take his answer bad, but in the same time, I ask just a simple answer because for me a function, if you put right parameters must works fine no?

And I try, in first time to use it, witout any code, just from Init(), and in this case no possibility for interference with any code:

just ‌as it is in documentation ChartGetInteger(0,CHART_WINDOW_HANDLE) and I repeat, if I write 0 as chartID, and I call the function, it works fine, but if I call the function from chart A for recover the chart B window Handle, doesn't work.

May be the problem is that the idchart I write in the second case is a long and not an int‌. I revover the idchart B with ChartFirst(), and this function return a long.

Do you have a solution for transform a long into an int or recover the idchart in int and not long.

Unfortunately, the answer is not always so clear. Many functions depend on other factors and other times coders (especially newbie coders) can do the most unexpected things in the real code that is not reflected in the forum explanation, which can be the cause of the problem.

So, you only have two alternatives:

  • ... either show example code (does not have to be your original code, just code that demonstrates the problem), so that we can compile and test it on our end in order ‌to either confirm or deny the problem as being either a bug in your code or a bug in MetaTrader itself,
  • or you try to figure it out yourself because we will not be able to offer any more assistance without example code to test.

As for you other question, that too cannot be answered properly without looking at the code. All I can say is that converting long to int or int to long is called Typecasting and it is in the documentation on how to use it, but I cannot guarantee that as being the problem without looking at your code.

Typecasting - Data Types - Language Basics - MQL4 Reference
Typecasting - Data Types - Language Basics - MQL4 Reference
  • docs.mql4.com
Typecasting - Data Types - Language Basics - MQL4 Reference
Patrick Chalindar
241
Patrick Chalindar  
Fernando Carreiro:

Unfortunately, the answer is not always so clear. Many functions depend on other factors and other times coders (especially newbie coders) can do the most unexpected things in the real code that is not reflected in the forum explanation, which can be the cause of the problem.

So, you only have two alternatives:

  • ... either show example code (does not have to be your original code, just code that demonstrates the problem), so that we can compile and test it on our end in order ‌to either confirm or deny the problem as being either a bug in your code or a bug in MetaTrader itself,
  • or you try to figure it out yourself because we will not be able to offer any more assistance without example code to test.

As for you other question, that too cannot be answered properly without looking at the code. All I can say is that converting long to int or int to long is called Typecasting and it is in the documentation on how to use it, but I cannot guarantee that as being the problem without looking at your code.

@whoeder1
  1. I just answered that question in another post, the call was correct but it global variable initialization, not in OnTick therefor had no value.

Thanks so much for your answer and for take time to answer me, really.

@ Fernando Carreiro:

You have rigth, it's not always so clear, but if I asked the question as I asked, it's because I know that I want and that I need, no necessary to have some code for this. And your answer is good, and I thanks to you!!

To add comments, please log in or register