MQL4 - automated forex trading   /  

Forum

Block EA only for a specific account

Back to topics list  | 1 2 To post a new topic, please log in or register

avatar
6
paulofoxstar 2008.06.24 22:40 
How to block an EA to work only in to determine actual I? Example Account: 202020
article

Creation of an Automated Trading System

You must admit that it sounds alluringly - you become a fortunate possessor of a program that can develop for you a profitable automated trading system (ATC) within a few minutes. All you need is to enter desirable inputs and press Enter. And - here you are, take your ATC tested and having positive expected payoff. Where thousands of people spend thousands of hours on developing that very unique ATC, which will "wine and dine", these statements soundб to put it mildly, very hollow. On the one hand, this really looks a little larger than life... However, to my mind, this problem can be solved.


avatar
396
ukt 2008.06.24 22:54 

avatar
6
paulofoxstar 2008.06.24 23:02 
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);


avatar
396
ukt 2008.06.24 23:13 

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...

avatar
6
paulofoxstar 2008.06.24 23:51 
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);




avatar
396
ukt 2008.06.25 01:56 

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


avatar
6
paulofoxstar 2008.06.25 16:47 
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

avatar
396
ukt 2008.06.25 16:57 
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


avatar
6
paulofoxstar 2008.06.25 17:01 
Do not you understand what you mean ..

avatar
396
ukt 2008.06.25 17:34 

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);


avatar
6
paulofoxstar 2008.06.25 17:47 
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);

Back to topics list   | 1 2  

To add comments, please log in or register