I've put the following together to try and alert me when a candle on a certain timeframe close above my Object Line it sends alert etc...However
at the moment it just spams me with alerts when price is above or below my line. So the alerting bit is fine but it doesnt seem to be taking the
timeframe into account and the candle close price.
Can some one please help...
1. Make it only send 1 or 2 alerts not continuous
2. Have it take the timeframe and candle close before sending the alert.
What i'm trying to achieve is : When a future 1hr candle closes above/below the price line send alert.
//+------------------------------------------------------------------+//| Candle Close.mq4 |//| Copyright 2019, MetaQuotes Software Corp. | //| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2019, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.00"#property strict#property indicator_chart_windowexternint Timeframe = PERIOD_H1; //Set TimeFrame of candle close above 60=1hr externstring LineName="MyLine1";
externcolor LineColor=AliceBlue;
externint LineStyle=STYLE_SOLID;
externint AlertPipRange=5;
externstring AlertWav="alert.wav";
externbool SoundAlert = true;
externbool PopupAlert = true;
externbool PushNotificationAlert = true;
externbool EmailAlert = false;
//+------------------------------------------------------------------+//| Custom indicator initialization function | //+------------------------------------------------------------------+intOnInit()
{
//--- indicator//---return(0);
}
//+------------------------------------------------------------------+//| Custom indicator deinitialization function | //+------------------------------------------------------------------+int deinit()
{
//----ObjectDelete(LineName);
//----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function | //+------------------------------------------------------------------+int start()
{
int counted_bars=IndicatorCounted();
ObjectCreate(LineName, OBJ_HLINE, 0, 0, Bid);
ObjectSet(LineName, OBJPROP_STYLE, LineStyle);
ObjectSet(LineName, OBJPROP_COLOR, LineColor);
ObjectSet(LineName, OBJPROP_WIDTH,3);
double val = ObjectGet( LineName, OBJPROP_PRICE1);
double testclose = iClose(NULL,Timeframe,0);
if (testclose > val)
{
if (SoundAlert) PlaySound(AlertWav);
if (PopupAlert) Alert("Price Closed Above Resistance on "+Symbol());
if (PushNotificationAlert) SendNotification("TRADE ALERT Closed Above "+LineName+" on "+Symbol());
if (EmailAlert) SendMail("HLine Alert on "+Symbol(),"price hit "+LineName+" on "+Symbol());
}
if (testclose <= val)
{
if (SoundAlert) PlaySound(AlertWav);
if (PopupAlert) Alert("Price Closed Below Support on "+Symbol());
if (PushNotificationAlert) SendNotification("TRADE ALERT Closed Below "+LineName+" on "+Symbol());
if (EmailAlert) SendMail("HLine Alert on "+Symbol(),"price hit "+LineName+" on "+Symbol());
}
return(0);
}
//+------------------------------------------------------------------+
Ask questions on technical analysis, discuss trading systems and improve your MQL5 programming skills to develop your own trading strategies. Communicate and share your experience with traders from anywhere in the world, answer questions and help beginners — MQL5.community is developing along with you. Initializing problem while compiling the...
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've put the following together to try and alert me when a candle on a certain timeframe close above my Object Line it sends alert etc...However at the moment it just spams me with alerts when price is above or below my line. So the alerting bit is fine but it doesnt seem to be taking the timeframe into account and the candle close price.
Can some one please help...
1. Make it only send 1 or 2 alerts not continuous
2. Have it take the timeframe and candle close before sending the alert.
What i'm trying to achieve is : When a future 1hr candle closes above/below the price line send alert.