@trunda - It is simple. You assignment does nothing. Both buy price and sell price would be equal to close, but close ON DIFFERENT BARS. Close in Monday (say entry) is not the same as say on Friday (exit). So your assumption that you are going to get zero profit is just nonsensical.
To have same price assign a number, not array with different values every bar.
To get better understanding of what is happening in your code and how functions work, use advice given here: How do I debug my formula?
For what it is worth currently your understanding of backtesting is zero, and you would do yourself a favour if you did NOT disable price bound checking as it is here to protect you from shooting yourself in a foot.
Trying to use prices outside H-L range in backtest is totally unrealistic.