seconds

 

hi guys, i need to set text every second but i also i need play sound every 5 seconds, do u have any idea?

this is what i wrote, but it dont work correctly

void OnTimer()
  {
     
     
            if(b()> d && c()>a)
             {
                 double spread = Ask-Bid;
      ObjectCreate("label",OBJ_LABEL,0,0,0);
      ObjectSet("label",OBJPROP_CORNER,1);
      ObjectSet("label",OBJPROP_XDISTANCE,400);
      ObjectSet("label",OBJPROP_YDISTANCE,150);
      ObjectSetText("label","spread = "+ DoubleToString(spread,Digits) +"\n"+ "  time = "+ TimeToStr(TimeCurrent(),TIME_SECONDS),25,NULL,red);
              //Comment("SOUND");
              // Comment(TimeCurrent());
              
               int t =1;
               if(t==1)
                 {
                  t++;
                 PlaySound("news");
                 Sleep(5000);
                 t--;
                 }
              
             }
 
ejmin ejoni:

hi guys, i need to set text every second but i also i need play sound every 5 seconds, do u have any idea?

this is what i wrote, but it dont work correctly

Something like this, if timer is set to one second

 static int second = 0;
 second++;

 if(second==5) {
  PlaySound("news");
  second = 0;
 }
 
Navdeep Singh:

Something like this, if timer is set to one second

Thank u, so much