Here's a base to work on:
:local alwaysRun true;
:while ($alwaysRun) do={
:if ([ping address=10.155.0.255 count=5] = 0 ) do={
# disable the routes
} else={
# enable the routes
}
}
Replace the IP address you want to ping and put the routes you want to enable/disable inside the script. Script will continuously run and ping 5 times - if no response, drop routes. If on next round of pings it pings, then it enables. You can add a delay at the start of the while loop to run every minute or so. If you want the script to keep working after reboot, then add it to Scheduler. More information can be found
https://wiki.mikrotik.com/wiki/Manual:Scripting and
https://wiki.mikrotik.com/wiki/Manual:System/Scheduler