This work presents a generic optimization framework using advanced mixed-integer programming techniques to integrate day-ahead and balancing markets with distributed energy resources such as storage, electric vehicles, demand response, and Transmission and Distribution System Operators' coordination schemes. The day-ahead model determines optimal initial energy scheduling, while the balancing model optimizes energy and reserve products for three market designs with varying Transmission and Distribution System Operators’ coordination. The framework is applied to the interconnected Greek-Bulgarian-Romanian power system, considering 2030 installed capacities.The model outputs illustrate market coupling scenarios among Romania, Bulgaria, and Greece, highlighting clear price signals and distributed energy resources flexibility. Results reveal the significance of a diverse energy mix for energy security and show that Transmission and Distribution System Operators’ coordination significantly influences ancillary service prices, with reductions of up to 80 % in certain scenarios. Net demand values determine electricity flow direction. Flexibility providers like storage can cover up to 100 % of the upward congestion management requirements and 11 % of upward balancing energy, helping smooth energy allocation from intermittent renewables. The impact of electric vehicle penetration on generation scheduling is minimal. The proposed model offers valuable insights for system operators, market participants, and policymakers, enabling them to provide accurate price signals and optimize resource allocation.The integrated day-ahead and balancing market models support efficient renewable energy integration, emissions reduction, enhanced grid stability, and investment in low-carbon technologies. This aligns with the United Nations Framework Convention on Climate Change goals, contributing to the development of sustainable and resilient energy systems.