I have indicator sending notifications.
I want to limit sending notifications to one or "n" per Period set on chart.
Do you have any idea how to limit it?
Thanks for help in advance.
Yes, use the Search in the top right corner of this page . . . try once per bar
I guess that you did try a search and that is how you found this old post.
It is relatively simple to do depending on how you want notifications limited by using a globally declared variable initially set to 0.
If you only want 1 notification per signal direction
If a buy signal, send notification and set the variable to 1
If a sell signal, send notification and set the variable to -1
When the code wants to send notification, check the value of the variable. If it is 1 don't send notifications for a buy signal. If it is -1 don't send notifications for a sell signal.
If you only want 1 notification per bar, make the variable datetime
When sending the notification save the value of Time in the variable
Only send notifications if Time!=the variable.
To add comments, please log in or register