In order to achieve both link prediction and sign prediction in signed networks, a new algorithm PSNBS was proposed on the basis of the similarity and structural balance theory, aiming to address the following two problems, namely, the imbalance between accuracy and complexity of link prediction algorithms based on the similarity in traditional social networks, and its incapability to be applied to signed networks directly. Firstly, combining with topology characteristics of signed networks and the choice of optimal step length, the 2-step and 3-step similarity scores of the two nodes based on structural balance theory were defined by effectively integrating attribute similarity and path similarity. Secondly, considering the different similarity contributions of paths of different step lengths, the adjustable influence factor of step length was introduced. Then, the total prediction score of the two nodes on the basis of the structural balance theory was defined. The absolute value of the score measures the similarity of the two nodes, i.e. the probability of the establishment of the future link, and the sign of the score is the sign prediction result of the future link. Thirdly, for the special case that the prediction score is 0, the concept of negative density of the node was introduced so as to predict the sign using the degree attribute of the node. Finally, link and sign prediction were completed according to the total prediction score of the two nodes and their negative density. Experiments were carried out on several data sets by usingAUC,AUCBSandPrecisionBSas the evaluation index. Results showed that the algorithm proposed can achieve higher accuracy in the prediction of future links and the sign prediction of known edges, which verified its effectiveness and robustness. Furthermore, PSNBS algorithm had higher prediction accuracy in sign prediction compared with two classical sign prediction algorithms CN and ICN.