# Sending Email once?

210

I'm editing some code I found that creates an Arrow when a double inside bar occurs. I would like it to send an email when it occurs as well.

I have used SENDMAIL() abd it works too well...I only want it to send an email when a new double inside bar occurs.  I would still like the arrow on all double inside bars.

I'm thinking that the solution would need to be an if statement and something around testing if the previous bar is the one. But I'm not an expert at the language, and dont know if/how that would work.

Here's the code - any help is greatly appreciated!

```#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow

double CrossUp[];

int init()
{
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
return(0);
}

int deinit()
{
return(0);
}

int start() {
int limit, i, counter;
double Range, AvgRange;
int counted_bars=IndicatorCounted();

//---- check for possible errors
if(counted_bars<0) return(-1);

//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i < limit; i++)
{
counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;

//bar 1 is an inside bar
if (High[i+1] < High[i+2] && Low[i+1] > Low[i+2])
{
//bar 2 is inside relative to bars 3 & 4
//high of bar 2 is below that of bar 3 && low of bar 2 is above low of bar 4
if (High[i+2] < High[i+3] && Low[i+2] > Low[i+4])
{
CrossUp[i+1] = Low[i+1] - Range*0.5;
SendMail("Inside Bar "+Symbol()+":"+Period()+"min","");
}
// OR high of bar 2 is below that of bar 4 && low of bar 2 is above low of bar 3
if (High[i+2] < High[i+4] && Low[i+2] > Low[i+3])
{
CrossUp[i+1] = Low[i+1] - Range*0.5;
SendMail("Inside Bar "+Symbol()+":"+Period()+"min","");
}
}
}
return(0);
}
```