How to limit ea only in one pair? - page 2

 

Wiseacre Mhlongo: You need to add this first: Hope it helps

Please read the previous posts! OP has already stated that he is not trying to restrict or protect his EA. Also, please use the SRC button!

 
Fernando Carreiro:

At this point it is very unclear what the OP wants and between all the posts we have already covered 3 possibilities:

  1. Preventing EA from running on other charts (by using Terminal Global Variables).
  2. Preventing interference of code on other EA's and/or Symbols (by using a "magic number" and checking for the same "_Symbol).
  3. Protecting or limiting EA by restricting the allowable Currency Pairs.

So now it is up to the OP to properly detail what he wants with some code examples.


Alright, thank you for your comments @Fernando Carreiro @Yohana Parmi @Wiseacre Mhlongo

It seems that I have to check option number 1 (as explained by @Yohana Parmi) with Global Variables. I am still working on it.

Thank you very much.

 
Donald Reeves Sihombing:

Alright, thank you for your comments @Fernando Carreiro @Yohana Parmi @Wiseacre Mhlongo

It seems that I have to check option number 1 (as explained by @Yohana Parmi) with Global Variables. I am still working on it.

Thank you very much.

Thanks

 
Donald Reeves Sihombing:

Alright, thank you for your comments @Fernando Carreiro @Yohana Parmi @Wiseacre Mhlongo

It seems that I have to check option number 1 (as explained by @Yohana Parmi) with Global Variables. I am still working on it.

Thank you very much.

Hi Donald, Were you able to get solution to the above problem. I also have a similar problem if you could assist. Thanks

 
OLUFEMI ODUNUGA:

Hi Donald, Were you able to get solution to the above problem. I also have a similar problem if you could assist. Thanks

Hello Olufemi,
Yes, you can use Global Variables.
I am not on the laptop right now. But I will try to explain. 
So, when you attach the EA on a chart (let's say EURUSD), the variable value will be 1. When you try to attach the same EA to other chart (let's say GBPUSD) it will not run because the variable is detected as 1. 
But if you remove the EA from EURUSD, theb automatically the variable become 0, and the EA can be attached to GBPUSD.
You can see the code example on the mql book document. I also find it there.
If you still have problem, you can inform me later.
 
try this
   int find_eur=StringFind(Symbol(),"EUR",0);
   int find_usd=StringFind(Symbol(),"USD",0);
   if(find_eur<0 || find_usd<0)
     {
     return;

     }

this code will search "eur" and "usd" word in symbol(), so this code will work even if micro or zero account with suffix like "_m" , "m" , "z"

hope this will help.

 
thank you very much Mr Fernando your example has helped me a lot. very grateful
 
John Tshwarelo Mabona #: thank you very much Mr Fernando your example has helped me a lot. very grateful
You are welcome!
 
Hello Fernando thanks for your help



this works very good with NZDUSD

but I want code to work with any NZD Pairs
like;
NZDUSD
NZDUSD#
#NZDUSD
NZDUSDm
NZDUSD.m



and also;
NZDCHF
NZDCAD
NZDJPY
and combination with #,m

so we can say that, "any symbol contains NZD inside of it"

How Can I do that?

thanks alot
 
Umut Dincer #:
Hello Fernando thanks for your help



this works very good with NZDUSD

but I want code to work with any NZD Pairs
like;
NZDUSD
NZDUSD#
#NZDUSD
NZDUSDm
NZDUSD.m



and also;
NZDCHF
NZDCAD
NZDJPY
and combination with #,m

so we can say that, "any symbol contains NZD inside of it"

How Can I do that?

thanks alot
Search for the substring nzd in the symbol name