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_buffers1#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 errorsif(counted_bars<0) return(-1);
//---- last counted bar will be recountedif(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 barif (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 4if (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 3if (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);
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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!