  In this paper we develop a statistical arbitrage trading strategy with two
key elements in hi-frequency trading: stop-loss and leverage. We consider, as
in Bertram (2009), a mean-reverting process for the security price with
proportional transaction costs; we show how to introduce stop-loss and leverage
in an optimal trading strategy.
  We focus on repeated strategies using a self-financing portfolio. For every
given stop-loss level we derive analytically the optimal investment strategy
consisting of optimal leverage and market entry/exit levels.
  First we show that the optimal strategy a' la Bertram depends on the
probabilities to reach entry/exit levels, on expected First-Passage-Times and
on expected First-Exit-Times from an interval. Then, when the underlying
log-price follows an Ornstein-Uhlenbeck process, we deduce analytical
expressions for expected First-Exit-Times and we derive the long-run return of
the strategy as an elementary function of the stop-loss.
  Following industry practice of pairs trading we consider an example of pair
in the energy futures' market, reporting in detail the analysis for a spread on
Heating-Oil and Gas-Oil futures in one year sample of half-an-hour market
prices.
