We study the two-boundary Temperley--Lieb O(n) loop model on Kazhdan--Lusztig bases of type A and B. We obtain explicit expressions of the ground state of the two-boundary Temperley--Lieb Hamiltonian by means of a coideal subalgebra of Uq(sl2). This ground state possesses a positive integral property. We conjecture that some components of the ground state are directly related to an enumeration of binary or permutation matrices.