The recent cost reduction and technological advances in medium-to large-scale Battery Energy Storage Systems (BESS) makes these devices a true alternative for wind producers operating in electricity markets. Associating a wind power farm with a BESS (the so-called Virtual Power Plant (VPP)) provides utilities with a tool that converts uncertain wind power production into a dispatchable technology that can operate not only in spot and adjustment markets (day-ahead and intraday markets) but also in ancillary services markets that, up to now, were forbidden to non-dispatchable technologies. What is more, recent studies have shown capital cost investment in BESS can be recovered only by means of such a VPP participating in the ancillary services markets. We present in this study a multistage stochastic programming model to find the optimal operation of a VPP in the day-ahead, intraday and secondary reserve markets while taking into account uncertainty in wind power generation and clearing prices (day-ahead, secondary reserve, intraday markets and system imbalances). A case study with real data from the Iberian Electricity Market is presented.