The problem of determining the European-style option price in the incomplete market has been examined within the framework of stochastic optimization. An analytic method based on the discrete dynamic programming equation (Bellman equation) has been developed that gives the general formalism for determining the option price and the optimal trading strategy (optimal control policy) that reduces total risk inherent in writing the option. The basic purpose of paper is to present an effective algorithm that can be used in practice. Keywords: option pricing, incomplete market, transaction costs, stochastic optimization, Bellman equation.