Integrating Distributed Energy Resources (DERs) and Micro-Grid (MG) into a system evolved the traditional power system. In spite of their significant advantages, MGs may result in volatility and uncertainty in the power systems. For reliable operation of the grid, energy trading among MGs should be optimized to maintain a fair trading price, maximize participants' profit, and satisfy network constraints. In this paper, the optimal power trading among multiple reconfigurable MGs is formulated as a Mixed-Integer Nonlinear Programming (MINLP) considering all energy resources and their dynamic prices. In spite of the other methods in the literature, the proposed method minimizes the total cost (increase sales and decrease purchases) and transmission loss considering all energy resources in the MGs. In order to flatten the load profile, a time-based load profile is considered for the demand response program. The performance of the proposed model is evaluated on an IEEE 6-bus network as well as a modified IEEE 33-bus test system. The results verify that the proposed method, (i) determines the best configuration among MGs with a switching reduction of about 30%, (ii) optimizes the power generation of energy resources with 12% reduction in energy production, and (iii) optimizes the power trading costs with a 10% reduction in costs compared with the basic model without DR and trade that is introduced as Scen.1 in this paper.