|
How to Code Alerts/Alarms for indicators?
Hello I'd like to learn more about how to code alerts.
I'm not a programmer but I have a head on my shoulders and am generally able to tinker with something, pick it apart, and put it back together again closer to the way I want it.
I've gone through some of the indicators with alerts and have copied the general alert functions I've seen to other indicators I've wanted to have alerts. I've had mixed results.
I notice that the main functions called for alerts are the Alert() function, the Comment() function, and the Playsound() function. So far I'm most familiar with the Alert() function. Is there a significant difference between Alert() and Playsound() for example?
The general problem I have is that I don't know how to code the alerts enough so that they are both noticeable on the one hand but not ridiculously distracting on the other. For example if using the Alert() function for some crosses and the indicator has not printed with finality on the current bar the alert might repeat over and over and over and I have trouble turning the alert off. Usually I have to change the time frame of the chart.
First of all is there a simple way to disable/deactivate the alert for the current bar only?
Second, is there a way to code an alert so that it isn't an unending annoying nuisance by introducing code that restricts the number of iterations or gives the alert a fixed duration? How would you code it?
One solution I see is to delay the alert until the next bar so that it isn't constantly changing but that does have the disadvantage of not being timely.
To avoid the hassle of berserk alarms on indicators, I've used the predetermined price alerts that one can set using the terminal window and it helps but it isn't ideal.
I'm also aware that Expert Advisors could be created to give alerts and that there is a button that can turn their alerts on and off easily. The problem I have with EAs, however, is that I notice that another important program I run concurrently with MetaTrader seems to experience interference when Expert Advisors are activated and runs sluggishly.
Are there any other solutions to this problem?
If there any indicators out there that have an alert code that avoids the pitfalls I have enumerated and can serve as a good example of how to code and alert could you please refer me to it and/or post it?
Thank you very much.
Last edited by Capablanca; 04-15-2006 at 10:10 AM.
|