Nowadays, benefits and advantages of renewable energies are clear for everyone. Lower cost of these resources (in compare with non-renewable resources), global demanding for the clean energy, limitations of fossil fuel resources, and so on, increase the popularity of renewable energies in power systems. However, the main problem is that the wind and solar power as two cheapest and biggest resources of renewable energy are variable, un-dispatchable, uncontrollable. Every change in the forecasted values of these resources could disturb the balance of generation and consumption in the electricity power network, which can lead to the instability of grid. Therefore, the flexibility of network shall be increased to neutralize the fluctuations of renewable resource. The Battery Energy Storage (BES) as the trusted and reliable energy resource can play a crucial role to maintain the flexibility of grid by instantaneous response to supply and demand variations. However, some constraints of BES such as minimum charge and discharge times, capacity, rate of charge and discharge could limit the generation/consumption of this resource in the real-time balancing. This paper provides a model for scheduling of BES and shifting demand response (SDR) in balancing ancillary service to improve the flexibility of grid. SDR program is proposed as the backup resource to cover the limitations of BES and improve the flexibility of grid. The objective function of proposed model is minimizing the real-time energy supply cost. The proposed model is formulated based on mixed integer linear programming (MILP) methodology. Moreover, the performance and advantages of the proposed model are investigated via a case study.