BUY_STOP does not change to BUY order

Hello, I have some problem with code execution in demo account. The problem is that some BUY-STOP orders remain on the terminal as BUY-STOP while they should have become BUY. The price goes up and the terminal still shows an open BUY-STOP order. If you try to close such an order manually, the terminal gives an error [invalid parameter]. The BUY-STOP orders are modified (quite often) according to the price changes. Do you think that 'sleep' will solve the problem?
Only after a restart of the terminal all BUY-STOPs are seen as BUY.
Thanks for your help.



Nothing in code "will solve the problem."