OP, you could find the solution if you posted on here
https://bitcointalk.org/index.php?topic=1114503.0(i know that's for seunjti dicebot's programmer, but since it's also script, maybe they can help you a bit).
~snip
Anyway,martingale is useless.Bustabit has an Auto-bet feature which supports martingale,if I remember this correctly,but this is a waste of time and BTC.
Yes, bustabit has that autobet feature. You can use martingale strategy on there, but you are only allowed to reset your bet once your bet win, that's why OP looking for a way to make his own strategy by adding the script to reset after xx losses.
Martingale doesn't waste your time, it wasted your money only.
I advise you gamble for fun and only as long as it's fun (and you have money you afford to lose/play with).
That's why OP want to reset his bet after xx losses in a row, with that, it could prevent him to get longer streak losses which will make he busted.