I have been trying to
put together a simple alert that will do the following:
Place an UP arrow
under a candle that has met a set of criteria (e.g., Close[1] - Open[1] > 10
points)
Place a DOWN arrow
above a candle that has met a set of criteria (e.g., Open[1] - Close[1] > 10
points)
The arrows should
also be placed for past candle sizes (but no emails).
The points should be
a volatile input meaning I can specify the amount depending on the chart I
attach it too.
Alert is based on the
last completed candle (i.e., ignores the current candle even it the condition
is satisfied). This is to avoid having multiple alerts for the same candle.
When alert is
triggered, an email is sent along with a message advising of the currency
pair and if it is a buy or sell (if possible, a chart).
Would appreciate if
someone can complete correct code for me.
Thanks
//+------------------------------------------------------------------+//| Candle size 2.mq4 |//| Tex |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Tex"#property link"https://www.mql5.com"#property version"1.00"#property strict//****************************************************//---- indicator parametersexterndouble Range=0.0010;
double Bull[],
Bear[];
//***************************************************//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
//---SetIndexStyle(0,DRAW_ARROW,EMPTY);
SetIndexArrow(0,225);
SetIndexBuffer(0,Bull);
SetIndexStyle(1,DRAW_ARROW,EMPTY);
SetIndexArrow(1,226);
SetIndexBuffer(1,Bear);
return(0);
//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
//---
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//---int counted_bars=IndicatorCounted();
int i;
int limit;
if(counted_bars<0)
if(counted_bars>0)
counted_bars--;
limit= Bars-counted_bars;
for(i=0; i<=limit; i++)
if(Close[i+1]>Open[i+1]+Range
)
{Bull[i]=Low[i]-0.0005;}
if(Close[i+1]<Open[i+1]-Range
)
{Bear[i]=High[i]+0.0005;}
//*************************************************** //*** Sends the e-mail//----------------------------staticdatetime Close_Time;
staticbool mail_flag_up=true;
staticbool mail_flag_dn=true;
if ( mail_flag_up && // This line is for sending an e-mail at the first occurence
Close_Time != Time[0] &&
Close[i+1] > Open[i+1] + Range
)
/*
{ SendMail("L/-" + Symbol(), "Buy" + Symbol() + Period() );
//SendMail("LONG", "test" );
Close_Time = Time[0];
// mail_flag_up=false; This line is for sending an e-mail at the first occurence
// mail_flag_dn=true; This line is for sending an e-mail at the first occurence
}
*/if ( mail_flag_dn && // This line is for sending an e-mail at the first occurence
Close_Time != Time[0] &&
Close[i+1] < Open[i+1] - Range
)
/*
{ SendMail("S\-" + Symbol(), "Sell" + Symbol() + Period() );
//SendMail("SHORT", "test" );
Close_Time = Time[0];
// mail_flag_dn=false; This line is for sending an e-mail at the first occurence
// mail_flag_up=true; This line is for sending an e-mail at the first occurence
}
*/return();
}
//+------------------------------------------------------------------+
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
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.
Hi
I have been trying to put together a simple alert that will do the following:
Place an UP arrow under a candle that has met a set of criteria (e.g., Close[1] - Open[1] > 10 points)
Place a DOWN arrow above a candle that has met a set of criteria (e.g., Open[1] - Close[1] > 10 points)
The arrows should also be placed for past candle sizes (but no emails).
The points should be a volatile input meaning I can specify the amount depending on the chart I attach it too.
Alert is based on the last completed candle (i.e., ignores the current candle even it the condition is satisfied). This is to avoid having multiple alerts for the same candle.
When alert is triggered, an email is sent along with a message advising of the currency pair and if it is a buy or sell (if possible, a chart).
Would appreciate if someone can complete correct code for me.
Thanks