I have this sample indicator that detects candlestick pattern.
The problem is, the alert is looping after the pattern was detected.
Is there a way to limit or set a number of how many time it can alert?
Hope anybody can help, here is the source code and thank you in advanced.
if(open3<close3 && open2>close2 && open<close && Allow_Alert == true) { createObj(time,low,217, clrGreen,"UP "); Alert("UP "); Allow_Alert = false; } else if(open3>close3 && open2<close2 && open>close && Allow_Alert == true) { createObj(time,high,218, clrRed,"DOWN "); Alert("DOWN "); Allow_Alert = false }
You need to define Allow_Alert in global scope and initialise it as false.
You should not check these conditions every tick as you are clearly testing bar closes right? so use a new bar function (do a search plenty around) and upon a new bar check your alert conditions.
If you do that and want the alert to reset upon a new bar then you can just set Allow_Alert to true upon a new bar, you could even not bother with the Allow_Alert if you only check on new bar and happy to alert every bar. However, if you want a different reset period or are not checking on a new bar then you need to code that and set Allow_Alert to true upon your conditions.
-
Please edit your post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
Messages Editor
Forum rules and recommendations - General - MQL5 programming forum (2023) - What if there is no tick that specific second?
-
Please edit your post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
Messages Editor
Forum rules and recommendations - General - MQL5 programming forum (2023) - What if there is no tick that specific second?
I can't seem to edit it now (wrote on mobile device). Good point, he should rather use OnTimer for his use case, as it will be more reliable for time conditions.
I think this might be another unfortunate AI code. OP - We use OnCalculate in indicators, and OnTick is for Expert Advisors.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have this sample indicator that detects candlestick pattern.
The problem is, the alert is looping after the pattern was detected.
Is there a way to limit or set a number of how many time it can alert?
Hope anybody can help, here is the source code and thank you in advanced.