This paper introduces a new two-stage, self-tuning least-squares digital signal processing algorithm for power-quality (PQ) indices estimation according to the power components and PQ indices definitions given in the IEEE Standard 1459-2000. The algorithm is based on the nonrecursive least error square technique accompanied with an tuning procedure, which generally improves the algorithm properties: the measurement range, the immunity to a random noise, convergence, and accuracy. The presented algorithm models typical signal distortions and it can be used for the real-time PQ indices estimation. In order to estimate signal spectra and fundamental frequency, current and voltage signals are processed in the first algorithm stage, whereas in the second stage, the power components and PQ indices are calculated based on the results obtained from the first stage. To demonstrate the efficiency of the proposed algorithm, the results of computer simulated and laboratory tests are presented.