The increasing penetration of renewable energy in the utility grid presents significant challenges caused by the fluctuating nature of this generation source. Energy storage is portrayed as a viable option to overcome these challenges and to ensure the integration of this source of energy. This paper proposes a strategy to optimally operate energy storage in a residential application. The optimal scheduling methodology is based on real-time electricity price and is aimed to maximize the profit of a hybrid energy system. This paper develops a Nonlinear programming optimization that would be suitable for other grid applications. Simulation results illustrate, that the presented optimal operation method is an effective measure to achieve maximum profits. Furthermore, the cost of storage has prevented its high penetration on electrical systems. Therefore, it is important to perform a cost analysis study to determine the cost of storing each kWh of electricity.