In this paper, we propose a novel approach to perform detection of stochastic signals embedded in an additive random noise. Both signal and noise are considered to be realizations of zero mean random processes whose only secondorder statistics are known (their covariance matrices). The method proposed, called Constrained Stochastic Matched Filter (CSMF), is an extension of the Stochastic Matched Filter itself derived from the Matched Filter. The CSMF is optimal in the sense that it maximizes the Signalto-Noise Ratio in a subspace whose dimension is fixed a priori. In this paper, after giving the reasons of our approach, we show that there is neither obvious nor analytic solution to the problem expressed. Then an algorithm, which is proved to converge, is proposed to obtain the optimal solution. The evaluation of the performance is completed through estimation of Receiver Operating Characteristic curves. Experiments on real signals show the improvement brought by this method and thus its significance.