Change your code to
int start() { static datetime lastTime = 0; if (lastTime == Time[0]) return(0); lastTime = Time[0]; CCI1=iCCI(NULL,0,periodCCI,PRICE_CLOSE,0); ...

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
---'lasttime' - expression on global scope not allowed----
Is there an easy fix to this error?
//+------------------------------------------------------------------+
//| CCI ALERT.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//---- input parameters
extern int periodCCI=14;
extern int HFEhigh=220;
extern int HFElow=-220;
double CCI1,CCI2;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
static datetime lastTime = 0;
if (lastTime == Time[0])
return(0);
lastTime = Time[0];
int start()
{
CCI1=iCCI(NULL,0,periodCCI,PRICE_CLOSE,0);
CCI2=iCCI(NULL,0,periodCCI,PRICE_CLOSE,1);
Comment(" CCI(",periodCCI,") = ",CCI1,"\n",
" Hook From Extreme HIGH=",HFEhigh,"\n",
" Hook From Extreme LOW=",HFElow);
if(CCI2 > HFEhigh && CCI1 < HFEhigh)
{
SendMail("1hrCCI SELL REVERSAL,CLOSE OR BREAKOUT!",Symbol());
Alert("1hrCCI SELL REVERSAL,CLOSE OR BREAKOUT!",Symbol());
}
if(CCI2 < HFElow && CCI1 > HFElow )
{
SendMail("1hrCCI BUY REVERSAL,CLOSE OR BREAKOUT!",Symbol());
Alert("1hrCCI BUY REVERSAL,CLOSE OR BREAKOUT!",Symbol());
}
}
{
SendMail("TEST FX Alert", "OPEN " +Open[0] + " LOW " +Low[0] + " HIGH " + High[0] + " BID " +Bid);
Print(" Daily Email Alert Sent ");
}
return(0);