In this paper, we address the Stacking Problem. Its objective is to determine the sequence of movements carried out by a stacking crane to store and retrieve a set of homogeneous blocks in a two-dimensional storage during a well-defined planning horizon in such a way that the number of relocation movements is minimized. We propose a heuristic algorithm that determines the target stack of each incoming block and those placed above the next to retrieve. Our heuristic algorithm also exploits the time periods in which the stacking crane is idle with the goal of improving its performance. The computational experiments reveal that our heuristic algorithm overcomes those approaches found in the related literature in terms of number of crane relocation movements. Its high performance and short computational times encourage its application in real-world environments.