The reason you're seeing entry at the low is because unless you specify otherwise, AmiBroker will try to confine your entry and exit prices to the actual high and low for the day. If yesterday's high is lower than today's low, then AmiBroker will "fix" your entry price to be today's low.
It should also be noted that if you are running against a portfolio of symbols then this backtest will generate overly optimistic results. You have essentially "cheated" by assuming that you can place an unlimited number of orders. For a full discussion of this topic, see this post: PositionScore / Ranking for trades taken “next day at limit”
Also, solutions involving ranking with StaticVarGenerateRanks will only partially solve the problem, as that still allows you to place more "orders" than you actually have capital for, i.e. they assume the use of an account with margin.
Sorry, I see that I missed a parenthesis on my previous post. The BuyPrice should be:
BuyPrice = max(Ref(H,-1), O);
This does not change your entry signal logic, so you shouldn't be getting any entries that you weren't getting before. It simply corrects the price at which the entry occurs. If you're still having problems, please post your updated code.