In this paper we investigate trading with optimal mean reverting portfolios subject to cardinality constraints. First, we identify the parameters of the underlying VAR(1) model of asset prices and then the quantities of the corresponding Ornstein-Uhlenbeck (OU) process are estimated by pattern matching techniques. Portfolio optimization is performed according to two approaches: (i) maximizing the predictability by solving the generalized eigenvalue problem or (ii) maximizing the mean return. The optimization itself is carried out by stochastic search algorithms and Feed Forward Neural Networks (FFNNs). The presented solutions satisfy the cardinality constraint thus providing sparse portfolios to minimize the transaction costs and to maximize interpretability of the results. The performance has been tested on historical data (SWAP rates, SP 500, and FOREX). The proposed trading algorithms have achieved 29.57% yearly return on average, on the examined data sets. The algorithms prove to be suitable for high frequency, intraday trading as they can handle financial data up to the arrival rate of every second.