Here's another option: The CAKE-autorate project is a script that is designed to handle this situation. Instead of your script changing the CAKE parameters on a fixed schedule, cake-autorate constantly measures the latency across your link and automatically adjusts the CAKE settings on the fly.
- If the latency is getting high, it cuts the CAKE speeds until it's back to baseline;
- If there's traffic but latency remains low, the script increases the CAKE speeds until it detects latency, then dials it back
Read the Github page to see if it might be suitable for you, or follow the CAKE-autorate topic on the forum