OptimalF and lot volume is always 1 in training. So the training results will normally be different than the test results. But a bad result in the test means normally also a bad result in training. Maybe there are other differences between test and training in your script, aside from the trade volume? Do you get the same number of trades?