A survey of the relevant literature shows that there have been many studies of the portfolio optimization problem, and that the number of these studies that have been based on heuristic techniques is quite high. We present a heuristic approach to the portfolio optimization problem using the artificial bee colony technique. As a test dataset, we use weekly prices from March 1992 to September 1997 from the following indices: Hang Seng in Hong Kong, DAX 100 in Germany, FTSE 100 in the UK, S&P 100 in the USA and Nikkei in Japan. This test dataset also includes daily prices from May 2013 to April 2016 from the XU030 and XU100 indices in Turkey. In this study, the cardinality-constrained mean–variance portfolio optimization model is treated as a mixed quadratic and integer programming problem, for which heuristic approaches are appropriate. The results of this study are compared with those of genetic algorithms, tabu search, simulated annealing, particle swarm optimization, a differential evaluation algorithm, a greedy randomized adaptive search procedure, an artificial bee colony, ant colony optimization, and a variable neighborhood search algorithm. The purpose of this paper is to present a relatively efficient and effective heuristic method to the portfolio optimization problem. The results show that the proposed artificial bee colony approach achieves these aims.