Issue with Backtesting and Optimization

I am using SetPositionSize(500,spsShares);
When I click on backtesting on some occasion it shows correct result and if I click on backtest again it shows same day exit and 0% Change, also a number along with Buy/Short in Trade column.
And when again I click on Backtest it shows correct result, So kind of random behavior.
That cause issue with Optimization as well.