I'm gonna try your script as it looks 1000x better.
Here is an error I get:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\bot2.php on line 132
BTC2 received, thanks. Good luck! (you'll need it if you plan to use martingale betting for very long...)
When you run PHP on a web server there is typically a 30s time limit.
You can increase that in the PHP code with:
set_time_limit(3600);
Which will mean an hour from the time that was executed.
Though if you put that in the correct loop (probably the innermost loop?) it will stop it from ever timing out.