- EA only works on one chart
- load a symbol using an EA
- load a data on chart
Here is an approach:
// representation of an instrument as a double value
// because global variables only allow double values
double encript(string symbol)
{
double value=0;
for(int i=0;i<StringLen(symbol);i++)
value += i*StringGetChar(symbol,i);
return(value);
}
int start()
{
...
double code = encript(Symbol());
double installed_ea = GlobalVariableGet("installed_ea");
// suppose you only want to trade eurusd
if(installed_ea==0) // not running over any other currency
if(Symbol()=="EURUSD") // it can be EURUSDm
{
//ea not running in any currency yet
//register as eurusd being managed by the expert
GlobalVariableSet("installed_ea",code) ;
}
// now test whether it is already running elsewhere
if(installed_ea!=0 && installed_ea!=code)
{
//"Expert is active at another currency; going away
return(0);
}
go_trading();
....
}
Thanks Abstract mind,
I think it will serve the purpose to some extent. Currently I have a similar approach i.e. initialize the global in init function and before that check if that global is already defined or not. What i want to do after that is to terminate the EA so that it does not call the start function again. Do you know if there is any way to programically remove EA if a certain condition is met?
Thanks,
Is there any way to find out if a certain EA is already loaded on a platform? For example if I want to run EA "ABC.mh4" only on one chart. how can i make sure that it is not already loaded on some other chart with in the platform? Any idea or feedback ?? Thanks..
i sell a robot that i programed. it works perfectly well only when u follow my instructions. +2348036860370
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use