The transition to decentralized and sustainable energy systems requires intelligent management strategies that can balance the interests of multiple stakeholders while optimizing grid performance. This paper presents a real-time dynamic pricing framework for virtual power plants (VPPs) using deep reinforcement learning to address the challenge of energy trading between prosumers, consumers and service providers. The pricing problem was formulated as a Markov Decision Process (MDP) using a Proximate Policy Optimization (PPO) agent to learn the optimal retail and purchase prices in a microgrid environment comprising grid users, a community battery and electric vehicles. The system minimizes participants’ operating costs, ensuring both economic efficiency and environmental sustainability. Our approach incorporates weighting parameters that allow dynamic adjustment of system priorities. Experimental results demonstrate that the agent successfully learns pricing strategies that balance stakeholder interests, with balanced priority configurations that achieve moderate benefits for service providers while reducing costs for consumers and prosumers.