SendNotification() function does not refresh after specified ticks

 

I have used void OnTick() to specify when to refresh SendNotification() function and after how many ticks to check if conditions have changed or they are the same then if changed then to send notification to the journal on MT4 but this only work on initialization then doesnt work therefore. Please help.

//--Push_Notification--//
bool Push_sent=False;
int Tick=0;
string Market_Direction="";

void OnInit()
{
    //--reset variables 
    Push_sent=False;
    Market_Direction="";
    Tick=0;
    
    //--send signal on initialization 
    IndAlert();
}
int start()
{
IndAlert();

return(0);
}
void IndAlert()
{

string Signal="";

//--Calculate Current BUYSELL value for signal
double BUYSELLValue=iAO(_Symbol,_Period,0);

//--Convert
BUYSELLValue=NormalizeDouble(BUYSELLValue,6);

//--Buy Condition 
   if (BUYSELLValue>SignalValue2)
   {
   
   //--reactive market when market changes direction 
   
   if(Market_Direction== "Down")
     { 
      //--Market update direction
      Market_Direction= "Up";
      
      //--Push reactive signals 
      Push_sent=False;
      }
   //--send signal if activated & Market changed direction after sending...
   if(Send_Push_Notification==Yes && Push_sent==False && Market_Direction== "Up")
     {
     
     SendNotification("...");
     //--Deactivate push notification after sending...
     Push_sent=True;
     }   
   
   }//--end of buy condition 
   
   //--Check for sell signal condition
 if(BUYSELLValue<0-SignalValue1)
   {
   //--reactive signals when market direction change 
   if(Market_Direction== "Up")
     {
     //--Update Market Direction 
     Market_Direction= "Down";
     //--Push reactive signal 
     Push_sent=False;
     }
     //--Send signal if activated & Market changed direction after sending...
   if(Send_Push_Notification==Yes && Push_sent==False && Market_Direction=="Down")
      {
       SendNotification("...");
        //--Deactivate Push notification after sending 
       Push_sent=True;
      }  
   
   }//--End of sell condition 
}

//--Tick function for push notification 

void OnTick()
{
//--increment tick
Tick+=1;
//--Send push notifications at tick 1
if(Tick==1)
{
IndAlert();
}

//--send push notification at tick 2
if(Tick==2)
{

}
//--comment current market direction 
Comment("Direction : "+Market_Direction);
//--reset tick at the end of function 
if(Tick==4){Tick=0;}

}
---End of Code---

 

In MQL4 the event handlers "OnTick()" and "start()" are the same thing and should not both be used at the same time.

"OnTick()"  is the new MQL4+ format and "start()" is from the old MQL4 format. So, use only the MQL4+ format of using "OnInit()" and "OnTick()" and remove ""start()" from your code.

Also, please use the Styler (Menu->Tools->Styler) to properly format your code. It is currently difficult to read and can lead to badly coded logic.

 
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
 
Keith Watford:
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
Thanks 
 
Teboho Edgar Rakotsoane: I have used void OnTick() to specify when to refresh SendNotification() function
  1. SendNotification does not store information, so there is no “refresh”.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

  2. IIRC, the maximum limit on emails, is just like SendNotification: “no more than 2 calls per second and not more than 10 calls per minute.” Add a Sleep(6) after the Send… and wrap a mutex around both (for multiple symbols).

 
William Roeder:
  1. SendNotification does not store information, so there is no “refresh”.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

  2. IIRC, the maximum limit on emails, is just like SendNotification: “no more than 2 calls per second and not more than 10 calls per minute.” Add a Sleep(6) after the Send… and wrap a mutex around both (for multiple symbols).

On SendNotification("...")  there is text inside the bracket so don't mind the the dots i didn't write it for security.