Email send every ticks

#1
Hello all,
I have a trouble in coding

I use ALERTIF function in each symbol, problem is email sends too much, (i want to recieve only one email)
Buy=cross(ref(C,-1),EMA(C,20));
AlertIf(Buy, "EMAIL", "Cross " + Name(), 1 );

The code in MQL4, it works, but I don't know how to change to AFL
static datetime AlertTime=Time[1];
if (Time[1] > AlertTime)
{
if (Email_Alert) SendMail("Cross", Symbol() + "," + TimeFrame );
AlertTime = Time[1];
}

Thanks for your help!
 
Last edited:
#2
try this code :)

Buy=cross(ref(C,-1),EMA(C,20));
CurrTime = LastValue(TimeNum());
if(CurrTime != StaticVarGet("ot")) {
AlertIf(Buy, "EMAIL", "Cross " + Name(), 1 );
StaticVarSet("ot", CurrTime);
}​
 

Similar threads