Optimized analysis method for indirect dark matter searches