- It has nothing to do with your loop except you shouldn't be alerting except on bar zero.
- You are alerting on a signal (ema5<ema18…). You can either:
- Remember the bar you last alerted on and don't repeat. Or
- Act on a change of signal.
MQL4 (in Strategy Tester) - double testing of entry conditions - MQL5 programming forum #1 2017.12.12
- Remember the bar you last alerted on and don't repeat. Or
-
You should stop using the old event handlers and IndicatorCounted() and start using new event handlers.
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 2016.05.11Your maximum lookback is 62.
- It has nothing to do with your loop except you shouldn't be alerting except on bar zero.
- You are alerting on a signal (ema5<ema18…). You can either:
- Remember the bar you last alerted on and don't repeat. Or
- Act on a change of signal.
MQL4 (in Strategy Tester) - double testing of entry conditions - MQL5 programming forum #1 2017.12.12
- Remember the bar you last alerted on and don't repeat. Or
-
You should stop using the old event handlers and IndicatorCounted() and start using new event handlers.
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 2016.05.11Your maximum lookback is 62.
Thank you for your response William, much appreciated.
I am looking at the links you sent in detail. Not quite sure how and where to apply the change of signal in my code though.
As you can probably tell I have cobbled together bits of code to get this far...
Cheers
Jon
To be clear, when i load the indicator I want to the arrows to be drawn historically where the condition has been met and only play a sound alert (once) when a new arrow appears as the condition is met again going forward.
Would appreciate a further clue on how to apply the 'change of signal' William if possible?
Thank you!
Do you see words with underlines? Those are links. They take you to more information.
You would know how, had you bothered to click on the provided link.
Do you see words with underlines? Those are links. They take you to more information.
You would know how, had you bothered to click on the provided link.
Was there any need for that rude reply? I am simply a novice looking for direction.
I am well aware they are links, I thanked you for them, and have "bothered" to go through them.
I applied the change of signal to my code and had no joy hence my question for further help.
Yes. I provided the code that tests for "a change of signal" yet you asked:
How To Ask Questions The Smart Way. 2004
How To Interpret Answers.
Dealing with rudeness.
MT4: Learn to code it.
MT5: Begin learning to code it.
If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.
Yes.
No. There wasn't.
You've certainly made your point though. Jeez.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I have an indicator I have coded that displays a buy/sell arrow when certain conditions are met. I want an alert sound when a new arrow appears and for the sound alert to play only once.
The code below continues to play the alert sound on every tick. I get why it does but how do I amend it so it plays only once but the Buy/Sell signals appear as normal? (I am having difficulty I think because of the int i for loop that is setup?) I have been searching and searching and i can't work it out.
Can anyone help a novice out please?
Many thanks
Jon