Need help on Indicator (ADX CROSS with Alerts)

Durai C

Master Trader
May 24, 2017
38
0
47
35
Thanks for reply. I did add the alert. But i am getting repeated alert. Its not stopping. So i posted here. Pls help me....
 

Enivid

Administrator
Staff member
Nov 30, 2008
16,139
837
144
Odessa
www.earnforex.com
Great! It means that you know some coding basics at least. Then you will have no problem fixing the indicator.
To prevent alerts from repeating indefinitely, you can use something like:
MQL4:
LastAlertTime = Time[0];
to remember the last time alert triggered and add it to the condition check like this:
MQL4:
if ((val1[0]!=EMPTY_VALUE) && (val1[0]!=0) && (SoundBuy) && (LastAlertTime != Time[0]))
 

Durai C

Master Trader
May 24, 2017
38
0
47
35
Thanks :) I comment there in coding. It is giving repeated alert and current one is no alert at all. I tried all possible ways. No luck. Can you pls make it work and post the file...
 

Enivid

Administrator
Staff member
Nov 30, 2008
16,139
837
144
Odessa
www.earnforex.com
Sorry, I am not here to code for you. You can apply the suggested changes if you want. If the current code does not give alerts at all, then you need remove the current alert code and to uncomment the lines that produced the alerts. Apply the LastAlertTime check to that code to prevent multiple alert calls of the same signal.
 

Enivid

Administrator
Staff member
Nov 30, 2008
16,139
837
144
Odessa
www.earnforex.com
That's a not a runtime error, that's a compilation error. To fix it, you need to declare LastAlertTime as a global variable in your code. You can do it like this, just below your line 25:
MQL4:
double b4plusdi,nowplusdi,b4minusdi,nowminusdi;
datetime LastAlertTime = D'';

You also need to add:
MQL4:
LastAlertTime = Time[0];
to each of the alert-calling scopes, otherwise it will not work.
 

Enivid

Administrator
Staff member
Nov 30, 2008
16,139
837
144
Odessa
www.earnforex.com
Your conditions are checking whether the last alert time is not on the current bar, but your code never assigns the last alert time to any bar's time.
As I have said, you need to add this line to do that:
MQL4:
LastAlertTime = Time[0];
In your current code, I would add it after line 98 and line 90.
 

Durai C

Master Trader
May 24, 2017
38
0
47
35
Sorry. I don't understand. Can you pls help me to finish this indicator. It will be helpful, if you could finish it.
 

Durai C

Master Trader
May 24, 2017
38
0
47
35
HI... I have tested and improved the codes. Now i have finished 90% result. Still i have few issues. Pls help me with this. Check line 64 and 66. Pls help me.
 

Attachments

Durai C

Master Trader
May 24, 2017
38
0
47
35
Hi Andy. Thanks for reply. I have made some changes in Line 69 and 71. Now Alert is not working properly. Is shows always down alert and Ask value is wrong. Can you pls help me.
 

Attachments