Price Alert

Mar 10, 2017
23
0
27
India
You need to set up a timer with EventSetTimer() and then use OnTimer() event to check if alert condition is fulfillied, do the alerts, and advance alert counter (to stop doing alerts after it reaches 100).
Hi @Enivid Could you please elaborate more on this?. I could not understand.
How to add that in this code
MQL4:
#property copyright ""
#property link      ""
 
#property indicator_chart_window
 
extern double SoundWhenPriceGoesAbove = 0;
extern double SoundWhenPriceGoesBelow = 0;
 
int init()
{
   if (SoundWhenPriceGoesAbove > 0)
   {
      ObjectCreate("SoundWhenPriceGoesAbove", OBJ_HLINE, 0, Time[0], SoundWhenPriceGoesAbove);
      ObjectSet("SoundWhenPriceGoesAbove", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet("SoundWhenPriceGoesAbove", OBJPROP_COLOR, Magenta);
      ObjectSet("SoundWhenPriceGoesAbove", OBJPROP_WIDTH, 1);
   }
   if (SoundWhenPriceGoesBelow > 0)
   {
      ObjectCreate("SoundWhenPriceGoesBelow", OBJ_HLINE, 0, Time[0], SoundWhenPriceGoesBelow);
      ObjectSet("SoundWhenPriceGoesBelow", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet("SoundWhenPriceGoesBelow", OBJPROP_COLOR, Magenta);
      ObjectSet("SoundWhenPriceGoesBelow", OBJPROP_WIDTH, 1);
   }
   return(0);
}
 
 
int deinit()
{
   ObjectDelete("SoundWhenPriceGoesAbove");
   ObjectDelete("SoundWhenPriceGoesBelow");
   return(0);
}
 
int start()
{
 
   if (ObjectGet("SoundWhenPriceGoesAbove", 1) != SoundWhenPriceGoesAbove)
     SoundWhenPriceGoesAbove = ObjectGet("SoundWhenPriceGoesAbove", 1);
   if (ObjectGet("SoundWhenPriceGoesBelow", 1) != SoundWhenPriceGoesBelow)
     SoundWhenPriceGoesBelow = ObjectGet("SoundWhenPriceGoesBelow", 1);
 
 
   if ((Bid > SoundWhenPriceGoesAbove) && (SoundWhenPriceGoesAbove > 0))
   {
      PlaySound("alert.wav");
   }
   if ((Bid < SoundWhenPriceGoesBelow) && (SoundWhenPriceGoesBelow > 0))
   {
      PlaySound("alert.wav");
   }
   return(0);
}
 

Joeyshen

Newbie
May 5, 2017
2
0
1
28
Hi Enivid,

When the market price hits the alert line, it will be removed. But would it be possible for the alert line to remain for multiple alert activation?
Thank you!!
 

Joeyshen

Newbie
May 5, 2017
2
0
1
28
Yes, you can remove or comment out the lines 75-76, 83-84, and 91-92 if we are talking about MT4 version. However, I am not sure you will like being flooded by lots of alerts.
Thank you!, but my apologies that I forgotten to state that i'm using MT5. May i know how was it done in MT5 too? Thank you!
oh and why i'm doing so its because since im trading more on 1 and 5min timeframe, so i could just shift the alert to the price for my next's trade rather than keep on inserting new indicator and keying in the input value.
 

Neville

Newbie
Sep 19, 2017
3
0
1
44
You can replace the SendMail() function with SendNotification(). Just make sure to remove the subject part, as notifications do not have subject, just text.
Hi Enivid, I am new to this. Thank you much for your service. I have tried to modify the Price Alert Indicator to Send Notification to my iphone, but I get errors when changing SendMail to SendNotification and try to compile. Would you, or someone, please provide an example of how this should be done?

Thank you very much, Neville.
 

Neville

Newbie
Sep 19, 2017
3
0
1
44
Something like this:
MQL4:
Yes, thank you. That is what I did, but I am getting an error (3 times, one for each occurrence of SendNotification).

Here is what I did (3 times) and the error (3 times):

MQL4:
if ((Ask > SoundWhenPriceGoesAbove) && (SoundWhenPriceGoesAbove > 0))
   {
      Alert("Price above the alert level.");
      PlaySound("alert.wav");
      SendNotification ("Price for " + Symbol() +  " above the alert level " + Ask, "Price for " + Symbol() +  " reached " + Ask + " level, which is above your alert level of " + SoundWhenPriceGoesAbove);
      ObjectDelete("SoundWhenPriceGoesAbove");
      SoundWhenPriceGoesAbove = 0;
   }
Error I receive:

'SendNotification' - wrong parameters count PriceAlert.mq4 74 7
 
Last edited by a moderator:

Enivid

Administrator
Staff member
Nov 30, 2008
13,918
623
144
Odessa
www.earnforex.com
Please do not forget to use code highlighting - it makes things much more readable.

As the error states, you are trying to call SendNotification() with a wrong number parameters. As you can see in my example, it takes only one parameter. Your call contains two parameters - the comma delimits them. When you use SendMail(), it takes two parameters - the subject of the email and the body of the message. When you use SendNotification() it can only take the message - there are no subjects in push notifications.
 

Neville

Newbie
Sep 19, 2017
3
0
1
44
Please do not forget to use code highlighting - it makes things much more readable.

As the error states, you are trying to call SendNotification() with a wrong number parameters. As you can see in my example, it takes only one parameter. Your call contains two parameters - the comma delimits them. When you use SendMail(), it takes two parameters - the subject of the email and the body of the message. When you use SendNotification() it can only take the message - there are no subjects in push notifications.
Thanks again! I removed the first area, before the comma, and it is good now.

MQL4:
 SendNotification("Price for " + Symbol() +  " reached " + Bid + " level, which is below your alert level of " + SoundWhenPriceGoesBelow);
 
Last edited by a moderator:

muscae

Trader
Oct 29, 2017
5
2
9
42
I am using one indicator for more than 2 years that cost me $10 but does anything that I need for my trades.
All I need is to be warned before price touches some level.
So this indicator as a field of Distance so we can choose how many pips before will be the warning. That warning could be pop up, email or push. It works with any draw line including trendlines, but u can exclude by the name or thickness. Also has a feature of changing the color of the line.
I am not here trying to spam the forum, just posting as way of inspiration for the features that I think this kind of indicator must have.
Here is the link https://www.mql5.com/en/market/product/6086
 

pierhh

Newbie
Dec 13, 2018
2
0
1
40
Hello,

Is it possible to alert/email when the price touches to the desire horizontal line after the candle closes?

Thanks.
 

pierhh

Newbie
Dec 13, 2018
2
0
1
40
Thank you for your response.
I am not a good coder, someone please help me to modify when price touches to the horizontal line and alert/mail me after the candle closes on the desire time flame.
 

oxyz88

Trader
May 11, 2020
1
0
6
32
Hi, buddy.. Greetings :)
I'm Joe from Indonesia.

A few days ago, i found your PriceAlert indicator on Google.
I really love it ♥
But, can i make a little request please?

if it possibble, i need the input coloums of "SoundWhenPriceGoesAbove" and "SoundWhenPriceGoesBelow" moved on the chart.
So it much more easier to input new value of those "SoundWhenPriceGoesAbove" and "SoundWhenPriceGoesBelow"

I attached the screenshot of it, please take a look.. :)
I make it with Excel, and attach it to chart screenshoot.

Please help..
Thankyou Before :)


Regards.
Joe.
 

Attachments