How can i change the current chart property programmatically?

 
Hi everyone,

I'm a newbie on this forum and MQL4 (build 950) and i hope that someone can help me to push me in the right direction!
So, I am trying to create a script to find the horizontal resistance/support lines, but have an issue.
There seems to be nothing wrong with my basic code, still i encounter an annoying behavior when testing/compiling from Editor.
 

It seems that on compiling the chartID=0, with means that the first chart (in my case AUDCAD) in my "Market Watch"  is activated/shown even before the OnInit() and even before the Input window comes up.
It is clearly and needless to say, that this EA is loaded on this chart. When i close this chart manually the EA is unloaded with it.

So, I want to change in code, this chart to my chart of choice, lets say "EURUSD".

I can coding the "OnInit()" event with :

     long CId=ChartOpen("EURUSD",PERIOD_H1);

that opens a new instance of this chart ("EURUSD") which i can manipulate in code. But for some code-snippets this seems to be useless, because all 'current chartid' functions (exp. Comment() ) keeps pointing to the current Chartid=0 namely "AUDCAD".

Perhaps there is a way to setting a certain "property" to this EA?
I can do this manually in the tester by starting up this script with "EURUSD".

The basic question is: Is there a way to change the "current chart" programmatically so that all current chart functions can point to the coded chart say : "EURUSD" ?

I searched around but found no topic that questioned this issue.



Thx to taking the time to review this!
 
 
 DeMike
 
DeMike17:
Hi everyone,


Try 
ChartSetSymbolPeriod(0,"EURUSD",_Period);
 
Kaleem Haider:
Try 
ChartSetSymbolPeriod(0,"EURUSD",_Period);


Hi Kaleem,

That's the one i needed ... works great and so simpel. ;)

Thank you ... best of wishes for the new year!


M.