Don't worry, your program will be layered: you start simple and with the most important parts. Then you gradually add the parts that are less important and/or refine certain core parts.Wow, that's a lot of work... I'm so Mickey Mouse right now. I actually just put a limit order on the last bar close. That seems OK, but maybe it's not?
Simply placing a limit order could result in that your order does not get filled. So you won't get the position you intent to have. Is that acceptable for your system?
The system I use is rather basic and probably not the most optimum solution. I want my orders to be filled, and am willing to wait only a few minutes maximum to get this filled. This gives for me the compromise between the best fill price (i.e. lowest additional cost) and the assurance that the order gets filled.
The price of an instrument moves in fixed price step sizes. I use this to determine what to do:
(i) If the spread is 1 stepsize then I cross the spread and submit a limit order. This will get filled immediately.
(ii) if the spread is 2 or more stepsizes then I initially submit a limit order with a price halfway between the bid and ask price. My order becomes therefore the best bid/offer price, hopefully drawing attention. I wait until the order gets filled, but wait a maximum of one minute. If after one minute the order is not filled I modify the limit price to cross the spread. This will get the order filled immediately.
This works satisfactorily for my small account and for the small order sizes I use. In case your order sizes are large might a more refined approach be necessary to make sure that orders are filled.
To ensure that no unfilled order lines remain at the broker do I specify the duration, after which the order is cancelled. This makes it easier to do order line management, and avoids that you need to maintain a data base with order lines and logic on how to handle open or remaining order lines.