Alert accumulates messages

 

My alert() function accumulates messages each time it triggers. I want it to output the messages only once and not to accumulate it in several lines. Somebody may help please. See picture below for perusal.


An alert () function accumulating messages

The required message is the one above while the unwanted messages have been highlighted in red pen. Thank you in advance.

 
How to you want us to help if you have not submitted any of your code?
 

Ok here is the code

void OnInit()
   {
   if(IsDemo()==false && IsConnected()==true)Alert("You are on real account");
   return;
   }
 

That just shows previous alerts.

How would you like it if you get multiple alerts while you are away from the computer and only the last one shows?

 
GumRai:

That just shows previous alerts.

How would you like it if you get multiple alerts while you are away from the computer and only the last one shows?

That is the point. I do not wish to be away from the computer while my EA is at work. My EA is not a robot. It is only a trading aid. It has been designed to be so. I don't think I like the previous alerts accumulated. As you can see the message is simple. It tells you when you have activated a live account, so as to be more careful the way you handle things. More so when the EA is still being developed and more things are being added. It is meant for the present, not the past. So any help on how I can handle the previous alerts? Thank you in advance.
 
macpee:

Ok here is the code

Your "image" shows multiple alerts all at the same time (to the second). So assuming that it is indeed triggered in the OnInit() and not in the OnTick()/OnCalculate() then you must have the indicator/EA open on multiple charts, and you have just opened MetaTrader application.

In other words, when you closed MetaTrader you had multiple charts with that indicator/EA on them which got all saved to MetaTrader's profile cache. Thus, when you opened MetaTrader and all those charts opened up at the same time, you got multiple alerts for all of them at exactly the same time.

Does that coincide with the behavior you describe?

 
FMIC:

Your "image" shows multiple alerts all at the same time (to the second). So assuming that it is indeed triggered in the OnInit() and not in the OnTick()/OnCalculate() then you must have the indicator/EA open on multiple charts, and you have just opened MetaTrader application.

In other words, when you closed MetaTrader you had multiple charts with that indicator/EA on them which got all saved to MetaTrader's profile cache. Thus, when you opened MetaTrader and all those charts opened up at the same time, you got multiple alerts for all of them at exactly the same time.

Does that coincide with the behavior you describe?


I think you are making some sense @FMIC. However, I will take a look of the program with respect to your suggestion and get back to you. Thank you in advance.
 
macpee:
I think you are making some sense @FMIC. However, I will take a look of the program with respect to your suggestion and get back to you. Thank you in advance.
@FMIC, you are absolutely right. In fact, it triggers even after changing input parameter and when I change the chart time frame and so on. However, I think I like it that way since it serves as a constant reminder that one is on live account, especially when you still have demo account that you are practicing with. The only problem is that it should not be queued.
 
macpee:
I think you are making some sense @FMIC. However, I will take a look of the program with respect to your suggestion and get back to you. Thank you in advance.
Either that or you just logged into a new account and all the charts reinitialised causing all the Indicators/EA's to reinitialise as well and run the OnInit() again all of them at the same time!
 
Then I think the working solution I need now is on how to clear the queues the moment the alert is triggered.
 
We cannot afford to have the EA on only one chart - that is not a part of the trading strategy.
Reason: