- How to block forex pair at MT4
- Communication between MetaTraders - Is it possible without read/write files? [B600+]
- Retard the alert several seconds
int init()
{
if (!IsDemo())
{
Alert("Invalid Account. Please contact EA Provider");
return(-1);
}
else
{
return(1);
}
}
//+------------------------------------------------------------------+
int start()
{
if (!IsDemo()) return(-1);
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
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
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);
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);
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use