In this paper we first describe the stochastic optimal control algorithm called ((OPTCON)). The algorithm minimizes an intertemporal objective loss function subject to a nonlinear dynamic system in order to achieve optimal value of control (or instrument) variables. Second as an application, we implemented the algorithm by the statistical programming system ((GAUSS)) to determine the optimal fiscal policy for Iran during the third development plan (1383 — 1379). The obtained results show that under optimal fiscal policies, the rate of economic growth and current account balance proposed in the third development plan will be achieved. Based of the findings having found compatible results therefore the determination of optimal macroeconomic policies for the Iran’s forth development plan is suggested.