Where and how should I put the stop level code after the EA is auto-generated?

 
When I automatically generate an MT5 EA, optimize it, and backtest it, there are periods when there are "invalid stops" errors and periods when there are not.
Is the stop level not set in the auto-generation?
What code should I add or modify after auto-generation and where?