how to modify this Alert?

 
void OnTick(void)
  {

   if(Bars<100)
     {
      Alert("Bars less than 100!");
      return;
     }
   if(IsTradeAllowed()==false)
     {
      Alert("Trade is not allowed!");
      return;
     }
}


I added few checkup lines to my EA. But the EA validation team comment to that like this:


"Please remove amount of spam in logs and alerts."


Yes the Alert popup until the problem fixed. But they saying it like a spam. So what you recommend for me? What kind of method use to pass this step? 

Thank you.

 
I can use "Print()". But i hope best thing is Alert(). But they see  it like a spam! So what i do now?
 

Thushara Dissanayake:
I can use "Print()". But i hope best thing is Alert(). But they see  it like a spam! So what i do now?

Hello, need more variable to point ..

use this.. chaiya

bool flag=false;
void OnTick(void)
  {

   if(Bars<100)
     {
      Alert("Bars less than 100!");
      return;
     }
   if(!IsTradeAllowed() && !flag)
      {
      flag=true;
      }
   if(IsTradeAllowed() && flag) 
     {
      flag=false;
      Alert("Trade is not allowed!");
      return;
     }
}
 
 
whroeder1:
You are looking at a signal (IsTradeAllowed.) Act on a change of signal.
          MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum

Thank you for all. You mean use a delay between  messages?

I checked it. When i compile, The Alert popup one time and stop correctly. After spend the input time (120 seconds), It again doing it continuously. I mean it not taken time delay on next round.


This is my code. Please kindly check if anything wrong with my side.

static bool openCondition=false; static datetime firstSeen;
bool prevCondition = openCondition; openCondition = (IsTradeAllowed()==false);   
if(openCondition){
    if(!prevCondition) firstSeen = TimeCurrent(); // Remember first seen
    else if(TimeCurrent() - firstSeen >= 120){      // Still set for 2 seconds
            Alert("Trade is not allowed!");
            return;
         }
 // else                                          // still waiting.
 }
 
Chaiya Srisawat:

Hello, need more variable to point ..

use this.. chaiya

Thank you for your reply. It not fixed by this code.
 
whroeder1:
You are looking at a signal (IsTradeAllowed.) Act on a change of signal.
          MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum
What you think about use long delay between messages?
 
I said nothing about a delay. I said something about a change.
 

I think 1 Alert is enough.  Alert on every tick is quit annoying (in my opinion) and fill up the log.
Alternatively you can change the comment saying the Trade is not allowed! " 

or make a Label on the chart saying Trade is not allowed! "

Or you can make alerts only when the EA tries to open / close a trade but unable to do so because Auto Trade is not allowed!

 
Lakshan Perera:

I think 1 Alert is enough.  Alert on every tick is quit annoying (in my opinion) and fill up the log.
Alternatively you can change the comment saying the Trade is not allowed! " 

or make a Label on the chart saying Trade is not allowed! "

Or you can make alerts only when the EA tries to open / close a trade but unable to do so because Auto Trade is not allowed!

Bro, Actually i want to check all things before go to a trade.
 
Thushara Dissanayake:
Bro, Actually i want to check all things before go to a trade.
So check it once if it is false give 1 alert only. 
Give an alert only when it changes to false, don't give alert on each tick while it remains false.
giving alert on every tick will fill up your logs.
Reason: