We consider a trader who wants to direct his portfolio towards a set of acceptable wealths given by a convex risk measure. We propose a black-box algorithm, whose inputs are the joint law of stock prices and the convex risk measure, and whose outputs are the numerical values of initial capital requirement and the functional form of a trading strategy to achieve acceptability. We also prove optimality of the obtained capital.