outsource mikrotik script development

Hello,
we need a script for our mikrotik that run every minutes and ping 2 destination ip and check packet loss then if packet loss will be more than X minutes disable some of our bgp networks and enable amangle rules that called XYZ when this step done it should wait X minutes then again run script and check ping and packet loss and if it they will be ok for X minutes and wil be stable then enable bgp network and disable that pbr mangle rule,
also there is some note :

  1. when script run every minutes it shiuld log packet loss value on mikrotik

if anyone can develop this script for us please send me private messages

thanks