In this study, the authors present a technique for code acquisition in optical code-division multiple-access systems using the recently introduced random optical codes. In these systems, the communication is divided in two parts: a synchronisation process and the data transmission. The main target of the study is to describe and analyse the new algorithm of synchronisation using Markov processes. Once described the code acquisition technique and established an estimation for the probability of false alarm (FA) of the proposed scheme, two different proposals for the optimisation of the code parameters are described. They are based on two different estimators for the probability of FA. The first one considers the expected value for the probability of FA. The second one is very much restrictive. It guarantees that the probability of FA is in a confidence interval. It takes the upper bound of the confidence interval as estimator for the probability of FA. Although the second one presents worse acquisition time, the authors consider that the gain provided by the first method is not sufficient enough to assume its loss in the reliability. Thus, the authors propose to guarantee the probability of FA in a confidence interval. A compromise between reliability and acquisition time is obtained with this second method.