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