Common code for all symbols

 

Sometimes, I need to use a code that will be not attached to a specific chart.

I mean, if I use the same EA in 2 charts(for ex EURUSD, GOLD), then the code of this EA runs twice for both charts which is not desirable.

For example, orders closing, I want to do once, for all the symbols... not each of them.

It looks in mql4, all the things are arranged for a specific chart, or I am mistaken?

Or I need to dig in amoung the orders of the hystory, should I do it for every chart? It can take huge time...

Some common code I need to use for all charts, any advice?

 
It all depends on how you write your code.

You can fitter your open trades by magic number, symbol, direction and others factors.

If you are willing to write a function that close all trades with no exclusion just add no filters and handle all of them...

Codebase is full of codes that accomplish what you need.
 
Fabio Cavalloni #:
You can fitter your open trades by magic number, symbol, direction and others factors.

If you are willing to write a function that close all trades with no exclusion just add no filters and handle all of them...

Codebase is full of codes that accomplish what you need.


thanks Fabio, I will try to use symbol name to filter it, allowing only one symbol to do order processing (for ex), while forbiding other symbols attempt to do the same code... 

Let me see what I get out of it...