Here’s a statement of results, completely without proof:
If you calculate the continued fraction for $\sqrt n$, where $m^2<n<(m+1)^2$, you’ll find that it takes the form $m+\frac1{a_1+}\frac1{a_2+}\cdots\frac1{a_2+}\frac1{a_1+}\frac1{2m+}\cdots$, and the whole symmetric sequence repeats infinitely after that.
It happens too that all the $a_i$ are in the range $1\le a_i\le m$, and in fact $a_i=m$ happens (if it does at all) only in the very middle of the sequence of $a_i$’s. At any rate, your solutions of the Pell Equation $X^2-nY^2=\pm1$ come only from the convergents that you get by cutting off your continued fraction just before the appearance of the $2m$.
As an example, the expansion of $\sqrt{14}$ is $3+\frac1{1+}\frac1{2+}\frac1{1+}\frac1{6+}\frac1{1+}\frac1{2+}\frac1{1+}\frac1{6+}\cdots$, and to get your solutions of Pell, you cut off just before the $\frac16$. The first one is $3+\frac1{1+}\frac1{2+}\frac11=\frac{15}4$, and surenough, $X=15$, $Y=4$ is a solution.
Want to get only the solutions $X^2-nY^2=+1$? Depends on the length of the repeating part of the expansion. If it’s even, all the valid convergents give solutions, while if it’s odd as with $\sqrt2=1+\frac1{2+}\cdots$, the first valid convergent gives $-1$, the second gives $+1$, the third valid convergent gives $-1$, and so on.