I can see from your code why it's different, but you should be able to find that out yourself. Follow the mighty manual:

"Unexpected results: If backtest results seem not to be right, first look into the log (LOGFILE must be set). Select one or two trades and check them from begin to end. Many parameters can affect trade results in many different ways - make sure to check them all."


By comparing two trades, you should see immediately why your script is sensitive on different bar periods.