How to stop continous alerts??

 

Hi guys, i have a problem with my simple expert advisor, it gives alerts whenever an inside bar forms as shown in code below but the alert rings continously until the next candle closes. how can i stop it to make it only ring once?? Thanks in advance

//+------------------------------------------------------------------+
//|                               Consolidation Candles Detector.mq5 |
//|                                       Copyright 2023, ELDigital. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#include <Trade/Trade.mqh>
#resource "\\Files\\email.wav"
#resource "\\Files\\ok.wav"
 
 int OnInit(){
   PlaySound("::Files\\ok.wav");
   return(INIT_SUCCEEDED);
 }

 void OnDeinit(const int reason){ 
 }

 void OnTick(){
 getConsolidationSignal(); 
 } 
    int getConsolidationSignal(){
    datetime time = iTime(_Symbol,PERIOD_CURRENT,1);
    
    double high1 = iHigh(_Symbol,PERIOD_CURRENT,1);
    double low1 = iLow(_Symbol,PERIOD_CURRENT,1);
    double open1 = iOpen(_Symbol,PERIOD_CURRENT,1);
    double close1 = iClose(_Symbol,PERIOD_CURRENT,1);
    
    double high2 = iHigh(_Symbol,PERIOD_CURRENT,2);
    double low2 = iLow(_Symbol,PERIOD_CURRENT,2);
    double open2 = iOpen(_Symbol,PERIOD_CURRENT,2);
    double close2 = iClose(_Symbol,PERIOD_CURRENT,2);
  
   //Consolidation formation
   if(close1 < high2){
      if(close1 > low2){
         createObj(time,low1,217);
         Print(__FUNCTION__," >Consolidation Signal...");
         Alert("Consolidation Alert");
         PlaySound("::Files\\email.wav");
    // Send a push notification
   string symbolName = Symbol();  
   string message = symbolName + " - Consolidation Signal Alert";
   int pushNotificationResult = SendNotification(message);

   if (pushNotificationResult)
 {
    Print("Push notification sent successfully.");
 }
 else
 {
    Print("Failed to send push notification.");
 }                                                
             return 1;
                }
             }
   return 0; 
 }
 void createObj(datetime time, double price, int arrowCode){
     string objName = "";
     StringConcatenate(objName, "Signal@",time,"at",DoubleToString(price,_Digits),"(",arrowCode,")");
     if(ObjectCreate(0,objName,OBJ_ARROW,0,time,price)){
        ObjectSetInteger(0,objName, OBJPROP_ARROWCODE,arrowCode);   
     }     
 }
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2023.11.01
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893