A new algorithm based on metaheuristics has been developed to perform stellarator optimization. This algorithm, which is inspired by the behaviour of bees and is called distributed asynchronous bees, has been used for the optimization under three criteria: minimization of B × grad(B) drift, Mercier and ballooning stability. This algorithm is tested by partially optimizing TJ-II and, afterwards, a three-period optimized configuration is found by performing a full optimization that starts from a three-period heliac.