Hydraulic control with switching valves can excite undesirable hydraulic and mechanical oscillations; hence, control performance is inadequate. There are different ways to cope with such oscillations. One way is to change the design or to add some damping elements which improve the attenuation of the oscillations. Another way is to actuate the system in an appropriate way - so that almost no unwanted oscillations are excited. This article illustrates that optimal feed-forward control theory can be used to obtain a realisable switching valve command which avoids ongoing oscillations for the case of a fast position step. A system composed of a dual-stroke cylinder with its piston chamber connected to the switching valves by some pipeline and its rod chamber to pre-pressurised accumulators for counterbalancing is modelled as a discrete dynamical system of order 9. The optimal control problem is conditioned such that the resulting valve signals can be approximately realised by the existing switching valves. For this realisation, the so-called ballistic mode of switching valves plays an important role. The theoretical results are tested experimentally on a proper test rig.