MQL4 EA defaults to symbol at top of Market Watch window

 

Hi,

I'm a relative newbie to MQL4 (but not programming).

I have created a new EA. I find when I run the EA it somehow defaults to the symbol at the top of the Market watch window, in this case USDCHF. I.e. the Symbols() function returns USDCHF. The output in the Experts window also refers to USDCHF which is very confusing.

Then the EA opens up a new chart window with USDCHF.

All of this is before program control is handed to my code in the OnTick function.

I can of course specify a different ticker when I do OrderSend and anything else but how can I stop MQL opening the unwanted new chart window and defaulting to USDCHF in the background?

I noticed a few other people have the same problem but no one has ever written a clear answer.

Thanks!

 
BoredMember:

I have created a new EA.

Then the EA opens up a new chart window with USDCHF.

All of this is before program control is handed to my code in the OnTick function.

Did you create the EA yourself, writing all the code or copy and paste from another?

Show your code that is executed before OnTick().

 
That sounds like you're opening with the debugger... 
 
nicholishen:
That sounds like you're opening with the debugger... 

Exactly, I am opening in the debugger! Is that just a debugger phenomenon I have no control oveR?

 
Keith Watford:

Did you create the EA yourself, writing all the code or copy and paste from another?

Show your code that is executed before OnTick().


Keith Watford:

Did you create the EA yourself, writing all the code or copy and paste from another?

Show your code that is executed before OnTick().


I borrowed bits of codes from others. There is no code executed before OnTick() as I only have an OnTick function, no other functions...

 
BoredMember:

Exactly, I am opening in the debugger! Is that just a debugger phenomenon I have no control oveR?


Yes. The debugger always launches the first symbol on the chart unless you otherwise specify in the Tools>Options>Debug menu.

 
nicholishen:

Yes. The debugger always launches the first symbol on the chart unless you otherwise specify in the Tools>Options>Debug menu.


Got it, that's incredibly helpful. To me it makes more intuitive sense that the debugger would pick up the symbol in whatever chart is currently in focus but so be it..


Thanks again

Reason: