Nowadays, the energy storage technology is bringing new opportunities to the power systems, not only providing the electric grid with regulation, reserve and backup services, but also filling the gap between the timing of production and consumption. This enables price arbitrage techniques, aimed at maximising the economic revenue obtained by charging or discharging the storage, based on the time variation of electricity prices. This paper shows how to optimise the operation of a storage device in presence of a PV generating plant, possibly combined with a local load. An optimisation technique based on a dynamic programming tool implemented with the open source Modelica language is here proposed and tested on different case studies. In particular, different storage sizes and losses models have been considered, as well as the dependence of the storage lifetime on the depth of discharge of its operational cycles. Finally, a payback analysis calibrated on present and future cost scenarios is presented and discussed.