This paper presents a method to find the optimal location, selection, and operation of energy storage systems (ESS- batteries-) and capacitors banks (CB) in distribution systems (DS). A mixed-integer non-linear programming model is proposed to formulate the problem. In this model, the minimization of energy loss in the DS is selected as an objective function. As constraints are considered: the active and reactive energy balance, voltage regulation, the total number energy storage devices that can be installed into network, as well as the operative bounds associated with the ESS (time of charge-discharge and energy capabilities). Three operating scenarios for the DS are analyzed by adopting the method proposed in this work. The first scenario is an evaluation of the base case (without batteries and CB), in which the initial conditions of the DS are determined. The second scenario considers the location of the ESS composed by redox flow batteries. Finally, the third scenario includes the installation of REDOX flow batteries with CB in parallel to correct operating problems generated by battery charging, and improve their impact on the grid. A master-slave strategy is adopted to solve the problem here discussed, implementing a Chu & Beasley genetic algorithm in both stages as an optimization technique. The proposed method is tested in a 69-node test feeder, where numerical results demonstrate its effectiveness.