Bar open sound alarm

 
Does anyone know an indicator/script which gives one sound alarm at the open of a new bar - or can code this?
 
int start()
{
    datetime PrevBarTime = Time[0];
    
    while (!IsStopped())
    {
        if (PrevBarTime != Time[0])
        {
            PlaySound("alert.wav");
            PrevBarTime = Time[0];
        }
    }
    
    return (0);
}
?