kymar,
i STRONGLY hope, this code example was not understood as a real strategy !!
it was an example.
indeed, i use stop buys in that way, sometimes 2 stop buys, 1 with a limit lower, or use a second entry at market also lower, when first stop was hidden (very complex programming)...