Download MetaTrader 5

MQL4 EA defaults to symbol at top of Market Watch window

To add comments, please log in or register
BoredMember
18
BoredMember  

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!

Keith Watford
Moderator
10564
Keith Watford  
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().

nicholishen
558
nicholishen  
That sounds like you're opening with the debugger... 
BoredMember
18
BoredMember  
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?

BoredMember
18
BoredMember  
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...

nicholishen
558
nicholishen  
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.

BoredMember
18
BoredMember  
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

To add comments, please log in or register