Block EA only for a specific account

 
How to block an EA to work only in to determine actual I? Example Account: 202020
 
I hold to achieve demo, see my code below .. but could not hold to account for a Real 202020 could help me?



int init()
{

if (!IsDemo())
{
Alert("Invalid Account. Please contact EA Provider");
return(-1);
}
else
{
return(1);
}

}

//+------------------------------------------------------------------+

int start()
{
if (!IsDemo()) return(-1);

 

like you do for !IsDemo()

can do for account maybe something like this?

int liveAccountNumber = 202020;


if( AccountNumber() != liveAccountNumber )
{
  Alert("Account Number not recognized");
  return(-1);
}
not completely clear wants, but is idea...
 
Hello I did the code below, it gives the message, but is opening orders, which is wrong, see



int liveAccountNumber = 134561;
//+------------------------------------------------------------------+

int init()
{

if( AccountNumber() != liveAccountNumber )

{
Alert("Esse EA está programado para a conta 134561");
return(-1);
}
else
{
return(1);
}

}

//+------------------------------------------------------------------+

int start()
{
if (!AccountNumber()) return(-1);

 

paulo, ok then - why not use "if (AccountNumber() != liveAccountNumber) return(-1);" in at beginning of start() instead of:

int start()
{
if (!AccountNumber())
return(-1);

...

reason? because start() still gets called each data tick. so what you had in init() may issue the Alert("..."); but you also need the if(...)return(-1); at top of start() too.

Please notice your code: if (!AccountNumber())

why? AccountNumber() is a typed function returning an int value - is not used like a bool so you must have something like this:

int start()
{
if (AccountNumber() != liveAccountNumber)
return(-1);

...

//do trading here if AccountNumber() is same as liveAccountNumber

...

return(0);

}//end of start()

can keep init() like it is but above should stop further execution of EA if running on account number different than liveAccountNumber.

hth

 
I am a newcomer in EA's, that would be asking too much if you could correct the code for me? I tried what you said and I could not
 
paulofoxstar wrote >>
I am a newcomer in EA's, that would be asking too much if you could correct the code for me? I tried what you said and I could not

If formatted, for example:

void start()
{
  int    i, b=0, bb=0, eb;
  string comm, st;
  string fn=Symbol()+Period()+" "+
         TimeToStr(BeginDate, TIME_DATE)+"-"+
         TimeToStr(EndDate, TIME_DATE)+".csv";

  for (i=Bars; i>0; i--)
  {
    if (Time[i]>=BeginDate && Time[i]<=EndDate)
    {
      if (bb==0) bb=i;       // фиксируем номер первого бара
      st=TimeToStr(Time[i], TIME_DATE)+Separator+
         TimeToStr(Time[i], TIME_MINUTES)+Separator+
         DoubleToStr(Open[i], Digits)+Separator+
         DoubleToStr(High[i], Digits)+Separator+
         DoubleToStr(Low[i], Digits)+Separator+
         DoubleToStr(Close[i], Digits)+Separator+
         DoubleToStr(Volume[i], 0);
      WritingLineInFile(fn, st);
      b++;
      eb=i;        // фиксируем номер последнего бара
    }
  }

  comm="Начало: "+TimeToStr(Time[bb], TIME_DATE|TIME_MINUTES)+"\n";
  comm=comm+"Конец: "+TimeToStr(Time[eb], TIME_DATE|TIME_MINUTES)+"\n";
  comm=comm+"Выгружено баров: "+DoubleToStr(b, 0);

  Comment(comm);
}

Why? unable cope with left justified programming code... need structure else unable/willing to keep file open longer than takes to close it... ;)

If you have source file layed out (formatted) block structure etc, then why not post?

Many able people live on forum, yes?

I will look but cannot make promises - nor can [I believe] others make promises.

Unless of course you contact money wanting person. For that, is link/article on forum to guide you in selection of [hopefully] decent programmer.

regards

 
Do not you understand what you mean ..
 

An idea: In computer programming, an indent style is a convention governing the indentation of blocks of code to convey the program's structure....

UNformatted:

int init()
{

if (!IsDemo())
{
Alert("Invalid Account. Please contact EA Provider");
return(-1);
}
else
{
return(1);
}

}

//+------------------------------------------------------------------+

int start()
{
if (!IsDemo()) return(-1);

formatted:

int init()
{
  if (!IsDemo())
  {
    Alert("Invalid Account. Please contact EA Provider");
    return(-1);
  }
  else
  {
    return(1);
  }
}

//+------------------------------------------------------------------+

int start()
{
  if (!IsDemo()) return(-1);
 
I think I could modify the code, see

int liveAccountNumber = 5513037;
//+------------------------------------------------------------------+

int init()
{

if( AccountNumber() != liveAccountNumber )

{
Alert("Esse EA está programado para a conta 5513037");
return(-1);
}
else
{
return(1);
}

}

//+------------------------------------------------------------------+

int start()
{
if (AccountNumber() != liveAccountNumber) return(-1);

Reason: