you don't show the horizontal frequency scale but I believe that the very small peaks have spacing 5 Hz, there are 100 Hz per major division, the large peaks are odd multiples of 50 Hz and the total frequency span is roughly 1000 Hz. The standard calculaton for THD is
THD = sqrt(v2^2 + v3^2 + v4^2 ...
where v1 is the amplitude of the fundamental and v2,v3.. up to some limit are the amplitudes of the harmoniics. The Maxfreq THD calculation appears to cover just the frequencies shown in the plot (harmonics below 1 kHZ) and appears to be correct under that assumption.
The nyquist frequency is the max frequency calculated by the fft and is half of the sampling rate of the instrument in sec^-1 or Hz. Without either the sampling rate or the number of points in the FFT it is not possible to find the nyquist frequency with the information given. However, it must be much, much higher than 1000Hz,maybe 50 times higher. But you will have that info. Anyway, going up to nyquist includes a lot more frequencies and raises the THD by a lot.
Where to stop the sum is a matter of judgment, especially if there is no high frequency filter or high frequency rolloff as there would be for an analog amplifier.
If you select out a chunk of the time domain waveform as is done here, you can get spurious high frequency content if the ends of the waveform are not trimmed carefully. But if the 10 cycles is a software choice I assume Matlab is doing that carefully.