Forex Factory (https://www.forexfactory.com/forum.php)
-   Platform Tech (https://www.forexfactory.com/forumdisplay.php?f=69)
-   -   Do-it-yourself alert builder kit (https://www.forexfactory.com/showthread.php?t=299520)

symon Nov 29, 2012 9:11am | Post# 81

You are posting decompiled code.

Anyway, to answer your question: as far as I know, the MQL4 instructions Alert() and SendMail() work the same way in EAs as they do in indicators. You place the instruction in your code at the point where you want the alert to occur.
Yep I apoligize, I was so tired not understanding how to get the signal...
So here is my code, I think I didn't have to know the indicator code because it's all about understanding "buffers"

Inserted Code
datetime start_time;
 bool buy = false, sell = false;

int indiSignal() {
double BuyArrow = iCustom(NULL, 0,"custom indi",/*indi parameters*/, 0, 1); //0=buffer0 for buy signal
  double SellArrow= iCustom(NULL, 0,"custom indi",/*indi parameters*/, 1, 1); //1=buffer1 for sell signal
  if (Time[0] != start_time) { // each new candle
  start_time = Time[0];
 if (BuyArrow < EMPTY_VALUE && BuyArrow > -1 && SellArrow == -1 && sell) 
 { 
 Print ("Signal BUYArrow = ", BuyArrow, " SellArrow = ", SellArrow); 
 sell = false;
 return (1);
}
 if (SellArrow < EMPTY_VALUE && SellArrow > -1 && BuyArrow == -1 && buy) {
 Print ("Signal SELLArrow = ", SellArrow, " BuyArrow = ", BuyArrow);
 buy = false;
 return (-1);
}
}
else {
if (BuyArrow < EMPTY_VALUE && BuyArrow > -1 && SellArrow == -1) buy = true;
 if (SellArrow < EMPTY_VALUE && SellArrow > -1 && BuyArrow == -1 ) sell = true;
}
   return (0);
}

You can find a more detailled explanation here:
http://forum.mql4.com/47490/page2

Hope it helps!

Fxx Trader Jan 20, 2013 2:54pm | Post# 82

Hi.

Am seeking help for a simple custom indicator with alert to show the price closed above or below * x * moving average after the price has crossed the moving average.

X... being any moving average indicator that is added to a chart.

Example :
On a 5M chart the price is in uptrend, and the moving average is below the price bar. At a later stage, the price bar cuts through the moving average in the downward direction and the subsequent bar after that closes below the moving average. The Alert should trigger at this stage.

Similarly the reverse for the price is in downtrend, and the moving average is abvoe the price bar. At a later stage, the price bar cuts through the moving average in the upward direction and the subsequent bar after that closes above the moving average. The Alert should trigger at this stage.

I have gone through many sites and many custom indicators but could not find any. If any custom indicator is already available the link / forum to the indicator may be intimated. I would appreciate if somebody could please help me.

Thanks in advance.

Fxx Trader

hanover Jan 21, 2013 10:03pm | Post# 83

Hi.

Am seeking help for a simple custom indicator with alert to show the price closed above or below * x * moving average after the price has crossed the moving average.

X... being any moving average indicator that is added to a chart.

Example :
On a 5M chart the price is in uptrend, and the moving average is below the price bar. At a later stage, the price bar cuts through the moving average in the downward direction and the subsequent bar after that closes below the moving average. The Alert should trigger at this stage.

Similarly the reverse...
I'm not taking on any more programming requests at this point.

Hence I suggest that you start a new thread, or post in one of the "I code your indicator/EA for free" threads. This thread has low visibility, and other programmers possibly expect the thread originator to deal with requests in their own thread.

m0b1us Jan 24, 2013 9:53am | Post# 84

1 Attachment(s)
Hi, can someone help me with this... I am getting these error messages and I'm not sure how to resolve it:

2;75;Crogram Files (x86)ATC Brokers MT4expertsindicatorsPrice Line Alert.mq4;80:57;'BuyValue' - variable not defined
2;75;Crogram Files (x86)ATC Brokers MT4expertsindicatorsPrice Line Alert.mq4;81:5;'BuyValue' - variable not defined
2;75;Crogram Files (x86)ATC Brokers MT4expertsindicatorsPrice Line Alert.mq4;89:58;'SellValue' - variable not defined
2;75;Crogram Files (x86)ATC Brokers MT4expertsindicatorsPrice Line Alert.mq4;90:5;'SellValue' - variable not defined

I have attached the file. The indicator works fine without the additional code from this thread. I want it to make a sound and popup window when the buy or sell line is reached and/or crossed. Also, do you know if this code will specify which currency pair the cross occurs on? Thanks!
Price Line Alert.mq4

hanover Jan 24, 2013 12:28pm | Post# 85

1 Attachment(s)
Hi, can someone help me with this... I am getting these error messages and I'm not sure how to resolve it:

2;75;Crogram Files (x86)ATC Brokers MT4expertsindicatorsPrice Line Alert.mq4;80:57;'BuyValue' - variable not defined
2;75;Crogram Files (x86)ATC Brokers MT4expertsindicatorsPrice Line Alert.mq4;81:5;'BuyValue' - variable not defined
2;75;Crogram Files (x86)ATC Brokers MT4expertsindicatorsPrice Line Alert.mq4;89:58;'SellValue' - variable not defined
2;75;Crogram Files (x86)ATC Brokers MT4expertsindicatorsPrice Line Alert.mq4;90:5;'SellValue'...
Given that this indicator doesn't fit the criteria needed for the DIY code (see post #1), I had to fix it manually.

Anyway, try the attached. It's the best I can do in the time that I have available. If it doesn't work, I suggest that you post in one of the "I code your EAs/indicators for free" threads, where your request will likely gain more visibility.
Price Line Alert.mq4

m0b1us Jan 24, 2013 1:29pm | Post# 86

Hey thanks, but you removed all reference to the sound alert so now all it does is create the lines on the chart, but no sound or popup alert. The sound alert worked on it, but I wanted a popup that also stated the currency pair and I only wanted the sound alert to go off one time. With this indicator, the sound alert goes off every time the price crosses over one of the buy/sell lines... and it doesn't say which currency pair is being alerted.

hanover Jan 24, 2013 2:07pm | Post# 87

1 Attachment(s)
Hey thanks, but you removed all reference to the sound alert so now all it does is create the lines on the chart, but no sound or popup alert. The sound alert worked on it, but I wanted a popup that also stated the currency pair and I only wanted the sound alert to go off one time. With this indicator, the sound alert goes off every time the price crosses over one of the buy/sell lines... and it doesn't say which currency pair is being alerted.
All I did was replace the PlaySound() instruction with an Alert() instruction, which creates a pop-up alert. MT4 pop-up alerts automatically play a sound along with the pop-up (and the sound file is selectable, as shown in the attached screenshot). I figured that having two sounds play would be redundant, hence I removed the PlaySound() instruction.

I didn't change the price-based conditions that cause the buy and sell alerts, hence whatever conditions were causing the sounds to occur (in the indicator that you posted) should now cause a pop-up alert (in the indicator I posted). The pop-up that I created should also show both the pair symbol and the timeframe of the chart that caused the alert, just as you requested.

If, as you say, the popups are not occurring, then I have no idea why. Perhaps you have disabled pop-up alerts (see the screenshot).
________________

[EDIT] I just tested the indy, and noticed the following:

1. The pop-ups are occurring correctly, at least according to the instructions in the code.

2. I was wrong about the red X in the screenshot disabling the pop-ups. It disables the sound only, not the pop-up from occurring altogether.

3. The code in the original indy is poorly written, for at least 3 reasons:
a) The lines are not removed from the chart when the indy is removed.
b) The pip distance parameters require that you enter the number of points, rather than pips. For example, if you want an alert to occur 5 pips before the line is reached, you must enter 50 rather than 5 (assuming your br0ker uses 5/3 digit quotes).
c) The alert (sound and/or pop-up) continues to trigger repeatedly, on every new price tick, provided that the condition is still met.
Click to Enlarge

Name: 2013-01-25_0801.png
Size: 57 KB

m0b1us Jan 24, 2013 2:38pm | Post# 88

Hi, well I don't know what's going on. I finally got it to work one time - and it is exactly what I want. However, I've tried it many other times and it has stopped working again. I've loaded different profiles and created new charts etc. and it won't alert - I need to figure out what's going on. But in the meantime - as you mentioned - it repeats the alert/popup every time the price crosses. Is there a simple way to limit the number of times the popup/alert goes off? Also - is there a simple way to automatically remove the lines once the indicator is removed? Thanks!

hanover Jan 24, 2013 3:34pm | Post# 89

4 Attachment(s)
Hi, well I don't know what's going on. I finally got it to work one time - and it is exactly what I want. However, I've tried it many other times and it has stopped working again. I've loaded different profiles and created new charts etc. and it won't alert - I need to figure out what's going on. But in the meantime - as you mentioned - it repeats the alert/popup every time the price crosses. Is there a simple way to limit the number of times the popup/alert goes off? Also - is there a simple way to automatically remove the lines once the indicator...
Try the attached.
Download the .mq4 and .ex4 files to your ..../experts/indicators folder.
Download the .mqh files to your ..../experts/include folder.

I've completely rewritten the indy, and have fixed the 3 points that I made. When one of the lines is reached, it sets the price of that line to 0, to prevent the alert from being triggered repeatedly. To reset the lines, edit the indicator parameters.

I've spent > 30 mins testing it, and it seems to work fine on my computer. I am running Win XP SP2, Pepperstone MT4 build 427.

That is as much as I can do. Writing free software doesn't pay my bills. If you want more help, please re-post on another thread.
Price Line alert v2.ex4
Price Line alert v2.mq4
hanover --- extensible functions.mqh
hanover --- function header.mqh

m0b1us Jan 25, 2013 6:42am | Post# 90

1 Attachment(s)
Thanks for all the help, I really appreciate it. However, there is some sort of bug where the alert goes off even when the buy/sell lines haven't been reached. I think it might have to do with how the lines are originally plotted on the chart about 1pip above and below the price line, and even though I click and drag the buy/sell lines into their places, whenever the price hits the original spot where the lines were plotted, the alert goes off.

Besides that, the only thing I would like to change is the fact that the buy/sell line disappears when it's been reached. I would like it to stay on the chart, because I use it as a support/resistance line.

I'll create another thread and see if someone can help me troubleshoot this. Thanks again for all the help. I have attached a text file, which was generated by MT4 - I think it shows some of the errors.
Price Line Alert.txt

hanover Jan 25, 2013 2:40pm | Post# 91

2 Attachment(s)
Thanks for all the help, I really appreciate it. However, there is some sort of bug where the alert goes off even when the buy/sell lines haven't been reached. I think it might have to do with how the lines are originally plotted on the chart about 1pip above and below the price line, and even though I click and drag the buy/sell lines into their places, whenever the price hits the original spot where the lines were plotted, the alert goes off.

Besides that, the only thing I would like to change is the fact that the buy/sell line disappears when...
Try the attached. Both of the problems you described should be fixed. Also, the alerts will trigger only once, until you either reset the alert by either (1) editing the indy settings (this will reset the alerts for both lines), or (2) move one or both lines (this will reset the alert for the moved line(s) only).

I have attached a text file, which was generated by MT4 - I think it shows some of the errors.
Ignore any unreferenced functions errors; they are irrelevant.
Price Line alert v2.ex4
Price Line alert v2.mq4

m0b1us Jan 29, 2013 1:24pm | Post# 92

This is looking great! The main bug left is when you switch between timeframes, it resets the lines - which causes the alerts to go off again and again. Also, when the lines are originally plotted on the chart, they are about a pip away from the price line and so the alert goes off sometimes before I even have a chance to drag the lines into place. Having the lines plotted about 10 pips away from the price line would be a lot better.

I would also like it if all of the superfluous code that causes the errors was removed. Is it possible to remove the includes and just have the indicator fully self-contained without the extra code? If you can do this and fix the bugs above, I'll send you a Paypal donation. Thanks again for all the help!

hanover Jan 29, 2013 2:52pm | Post# 93

2 Attachment(s)
This is looking great! The main bug left is when you switch between timeframes, it resets the lines - which causes the alerts to go off again and again. Also, when the lines are originally plotted on the chart, they are about a pip away from the price line and so the alert goes off sometimes before I even have a chance to drag the lines into place. Having the lines plotted about 10 pips away from the price line would be a lot better.

I would also like it if all of the superfluous code that causes the errors was removed. Is it possible to remove...
Switching between TFs is not a bug. Whenever you switch TFs, MT4 always resets ALL of the indys on your chart, hence (in this case) it re-plots the lines and resets the alert flags. (In techno-speak, a reset causes all of the code in the init() module to be re-executed). I don't know how to get around this, short of having a separate script that plots the lines. Then you'd need to drag the script onto the chart as a separate operation, which is arguably cumbersome.

The lines should now plot 10 pips away from the current price, in the attached version.

The messages caused by the superfluous functions don't affect the running of the indicator. The compiler excludes them from the .ex4 file, and the warning messages are simply telling you that it's doing so. The attached versions are self-contained; however, please don't ask me to modify them further now, as I've removed all of the code in my function libraries.

No need for a PayPal donation, but thanks for the offer.
Price Line alert v2.mq4
Price Line alert v2.ex4

shilox Feb 1, 2013 6:29pm | Post# 94

1 Attachment(s)
Hello Hanover,
Please can you add alert to this indicator.
I tried doing so from the example on post #1, but couldn't.
Thanks in advance.
Hi lo ZZ.mq4

hanover Feb 2, 2013 4:47am | Post# 95

Hello Hanover,
Please can you add alert to this indicator.
I tried doing so from the example on post #1, but couldn't.
Thanks in advance.
I'm sorry, but this indicator doesn't fit the paradigm outlined in post #1. There is a significant amount of work involved, as the code is not easy to follow. Also, you haven't specified the conditions upon which you want alerts to occur.

Perhaps you could try posting in one of the "I code your EAs/indicators for free" threads, and a programmer with more spare time than I have might be kind enough to look at it for you. Good luck.

boeing Feb 4, 2013 10:19am | Post# 96

1 Attachment(s)
good afternoon

asking for help for a basic email alert.
I would like the alert to come when the RSI draws a line on the first indicator data (as shown in red in the picture);
Is it possible?
thanks for the help
rsi mt4.docx

hanover Feb 4, 2013 12:36pm | Post# 97

good afternoon

asking for help for a basic email alert.
I would like the alert to come when the RSI draws a line on the first indicator data (as shown in red in the picture);
Is it possible?
thanks for the help
I expect that it's possible, but you haven't explained the precise conditions upon which you want the alert to occur.

Anyway, I'm currently too busy with other projects to take on any more programming work. I suggest that you start a new thread, or post in one of the "I code your indicator/EA for free" threads. This thread has low visibility, and other programmers possibly expect the thread originator to deal with requests in their own thread.

boeing Feb 5, 2013 2:44am | Post# 98

thanks for the reply Hanover
good luck with your coding

jicssbr Feb 19, 2013 12:51pm | Post# 99

1 Attachment(s)
Hello Hanover,

I'd like to have a pop box showing the currency pair and an arrow on the chart for the MACD lines crossing on a zero lag MACD. Is that something you can do?

Thank you very much.

jicssbr
ZeroLag MACDline.mq4

hanover Feb 19, 2013 2:34pm | Post# 100

4 Attachment(s)
Hello Hanover,

I'd like to have a pop box showing the currency pair and an arrow on the chart for the MACD lines crossing on a zero lag MACD. Is that something you can do?

Thank you very much.

jicssbr
Try the attached:
--- Download the .mq4 and .ex4 files to your ..../experts/indicators folder.
--- Download the .mqh files to your ..../experts/include folder.

To turn the arrows off, set ArrowSize=0. The alert parameters are explained in the 'OPERATIONAL NOTES' section in post #1.
ZeroLag MACD.mq4
ZeroLag MACD.ex4
hanover --- function header.mqh
hanover --- extensible functions.mqh


© Forex Factory