A new N finite steps optimal control algorithm of a discrete state space model, stochastic regulating control system is presented. The new algorithm has the conditional expectation in its performance index equation. It uses dynamic programming to obtain the controller for each step.