Add a flag
bool Alerted = false; int start(){ ... ... // somewhere put a reset of the flag to false after alert is triggered ... if(SellAlert && Alerted == false) { if(ExtMapBuffer8[i]>=ExtMapBuffer1[i]) { SendMail("TestSignal:"+Symbol()+" SELL ALERT ",Symbol()+" has generated a SELL Signal "+MarketInfo(Symbol(),MODE_ASK)+" on the"+Period()+" minute chart."); Alert("TestSignal SELL ALERT:"+Symbol()+" entered a SELL ZONE at "+MarketInfo(Symbol(),MODE_ASK)+" on the "+Period()+" minute chart."); Alerted = true; }
many thanks!!
Forex Trader:
many thanks!!
many thanks!!
Hi
Is the Boolean Alerted written in Init()?
But it only initialized once, then the Alerted will stay True forever.
Well not if you set it back to zero somewhere.
And that depends on the strategy really.
You can have what is called a single shot which means an alert is given for every time the level goes above or below a pre defined value.
But you can also have a flip-flop this setup means it will oscillate alerts between high and low values, and will not give multipe alerts for a series of high breaches so to speak.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am trying to learn to write this code and cannot seem to figure out the problem here. \Basically once the alert condition is met the indicator continues to send alerts on every tick. How can I change the code so that only one alert is sent when the condition is met? Any help would be greatly apperciated.