The code you’ve shown never sets the BuyPrice variable. In addition, your Buy statement is incorrect. Try something like this:
Buy = Ref(buySignal,-1) AND L < buyLimitPrice;
BuyPrice = IIf(Buy, Min (open , buyLimitPrice), -1);
Translation: Only generate an actual Buy signal when your entry conditions were met yesterday AND today’s price falls below the limit price. Set the entry price for the trade (BuyPrice) to be the limit price unless the open gaps down below the limit, in which case use the open instead of the limit as your entry price. If there was no Buy signal today, then just set the BuyPrice to -1.
The code that I gave you should work for a simple back test on EOD data where you’re not concerned with having competing orders or having more setups (limit orders) than you have available capital to fund. If you’re doing real-time scans or back tests and trying to hook that up to some type of auto trader, then you’ll need to put some more thought into it.
My advice would be to test the AB output in isolation first. When you 100% comfortable that it’s behaving as you want, THEN add the auto trading to the mix.
Just because you paid for your auto trader software doesn’t guarantee that it works perfectly, and it most certainly doesn’t imply that you’re actually using it correctly. My advice remains the same: make sure you understand how AmiBroker works, and that your logic is producing the results you expect. Then do the same with the Auto Trader. If it’s being driven by a chart showing real-time data, then how does it behave when your chart gets redrawn but you’re still on the same 10-minute bar?
For future reference, if you want people to help you solve a problem it would be best if you provided as many details up front as possible. In other words, try to make it easy for others to help you. When you give a few more details each time you post another message, it means you’ve been expecting people to guess what you’re trying to do which is counter-productive.