Any one with idea to get the code working properly

 

I use this code to disallow more than 2 EA on one mt4 terminal but its operations is not consistent,pls any assistance. Thanks

string GLOBAL_NAME = "myeaname";

int init()
{
  //...
  GlobalVariableSet(GLOBAL_NAME, WindowHandle(Symbol(), Period()));
  
  return(0);
}

int nameea = 0;

int onint()
{
  nameea == 0)
  {
    if(GlobalVariableGet(GLOBAL_NAME) != WindowHandle(Symbol(), Period())) 
    {
      nameea = -1;

      IndicatorShortName("Program is disabled (duplicate is found)");

      Print("Only 1 EA allowed. This one is will not run .");
Expert remove()
      return(-1);
    }
    else
    {
      nameea = +1;
    }
  }
  else if(nameea == -1)
  {
    return(-1);
  }
  //...
}
 
chukwudi joshua obiekwe:

I use this code to disallow more than 2 EA on one mt4 terminal but its operations is not consistent,pls any assistance. Thanks

there are some clear errors in the syntax of your code. The snippet you have sent here will not compile 

 
chukwudi joshua obiekwe: ,pls any assistance. 
  1. Do not post code that will not even compile. We assume you know the language.

  2. Post all relevant code.

    How can we know whether you used strict or not.

    Always use strict. Fixing the warnings will save you hours of debugging, but you must understand the differences.

  3. Where do you call onint?

  4. What is the purpose of nameea? It is unnecessary.
 
William Roeder #:
  1. Do not post code that will not even compile. We assume you know the language.

  2. Post all relevant code.

    How can we know whether you used strict or not.

    Always use strict. Fixing the warnings will save you hours of debugging, but you must understand the differences.

  3. Where do you call onint?

  4. What is the purpose of nameea? It is unnecessary.
It's a typo error mean to type  void OnTick() not
int onint()
 
Chukwudi Joshua Obiekwe #:
It's a typo error mean to type  void OnTick() not

Always the last initialized EA instance is allowed to run. Even if you change timeframe the EA init will set the handle of that chart. 

 
Laszlo Tormasi #:

Always the last initialized EA instance is allowed to run. Even if you change timeframe the EA init will set the handle of that chart. 


What of calling "Expertremove()" when any is detect..?
 
chukwudi joshua obiekwe #: What of calling "Expertremove()" when any is detect..?

After you return.

 
William Roeder #:

After you return.

i have removed all errors on the code using #property strict and it compile good..

but i just want to know what am doing wrong now,

#property strict

string GLOBAL_NAME = "myeaname";

int init()
{
  //...
  GlobalVariableSet(GLOBAL_NAME, WindowHandle(Symbol(), Period()));
  
  return(0);
}

int nameea  = 0;

void OnTick()
{
  if(nameea  == 0)
  {
    if(GlobalVariableGet(GLOBAL_NAME) != WindowHandle(Symbol(), Period()))
    {
      nameea  = -1;


    IndicatorShortName("Program is disabled (duplicate is found)");
      Print("Only 1 EA allowed. This one is will not run .");
      ExpertRemove();
    }
    else
    {
      nameea  = +1;
    }
  }
  else if(nameea  == -1)
  {
    return;
  }
  //...
}
 
still waiting any update or assistance on above code