How to enter the trade at a SPECIFIC price when uncertain if limit or stop order should be used?

 
So I have a certain trading logic that when met I want to enter the trade at the price of the previous close.

This of course cannot be done  using a market order due to spread between ask and bid.

However, as the candle closes and the next one opens, placing a limit order automatically where the last close was causes errors with my EA (pineconnector). 

The market bid/ask can often be on the wrong side of the limit order.

Why doesn't the MT5 accept the limit order thats on the wrong side of the market? 

For example, buy limit above market price should trigger and give me a better price. But this is not possible in mt5. Also if I use buy stop, then the problem occurs when the market price is slightly above buy stop order.

Why isnt there a simple, straightforward way to say I want to enter at this price, if bid/ask hits it, enter, if not, no trade. Is there a way to achieve this or not? Thanks!
Reason: