A too small lookback value would normally give a different error message. But without seeing what you did in your code to get that error, it's only speculation. The first thing to do when you get error messages is looking for mistakes in your code. Optimizing the trail slope alone is obviously not a mistake, so you have to look again.