One confusion with the 'order_optimal_portfolio' may be that it places the orders all at once (unlike the 'order_target' methods). Therefore, there's no need to loop through all the stocks one wants to order. Simply set up a pandas series, or python dict, associating each security with it's desired weight. Use that series to create a 'TargetWeights' objective, then use that objective when executing the 'order_optimal_portfolio' method.
Any securities not in 'TargetWeights' will be assumed to have a target of 0 percent. Therefore, 'order_optimal_portfolio' will try to close any open positions without a weight. This is the cause of the behavior "the algo seems to purchase each stock, sell most minutes later and hold only a couple overnight with the wrong weights". Looping through 'order_optimal_portfolio' with a single weight in each iteration will try and close positions from previous iterations (because it assumes a zero weight).
The 'order_optimal_portfolio' method also checks for 'can_trade'. It's not required to explicitly do this. It won't cause an error if a security can't trade (though will log a warning). However, there could be reasons to check if a security can trade and one can still do it anyway. One may always want to hold a fixed number of securities so verifying they all can trade may be important.
@Blue Seahawk uses the 'positionConcentration.with_equal_bounds constraint (not objective) to get equal weighting. If using other constraints this is a good way to go. Other constraints may want to tweek the desired weights so it's good to give those weights a range. However, for plain down and dirty order a fixed weight of each security then using the 'TargetWeights' objective is very straightforward.
See attached algorithm. Take a look at the logs for the trades which were placed. Good luck.