rewriting trade logic to support trailing stops