Context. Several observations of stellar jets show evidence of X-ray emitting shocks close to the launching site. In some cases, the shocked features appear to be stationary, also for Young Stellar Objects (YSOs) at different stages of evolution. We study the case of HH 154, the jet originating from the embedded binary Class 0/I protostar IRS 5, and the case of the jet associated to DG Tau, a more evolved Class II disk-bearing source or Classical T Tauri star (CTTS), both located in the Taurus star-forming region. Aims. We aim at investigating the effect of perturbations in X-ray emitting stationary shocks in stellar jets; the stability and detectability in X-rays of these shocks; and explore the differences in jets from Class 0 to Class II sources. Methods. We performed a set of 2.5-dimensional magnetohydrodynamic numerical simulations that modelled supersonic jets ramming into a magnetized medium. The jet is formed by two components: a continously driven component that forms a quasi-stationary shock at the base of the jet; and a pulsed component constituted by blobs perturbing the shock. We explored different parameters for both components. We studied two cases: a jet less dense than the ambient medium (light jet), representing the case of HH 154; and a jet denser than the ambient (heavy jet), associated with DG Tau. We synthesized the count rate from the simulations and compared with available Chandra observations. Results. Our model explains the formation of X-ray emitting quasi-stationary shocks observed at the base of jets in a natural way, being able to reproduce the observed jet properties at different evolutionary phases (in particular, for HH 154 and DG Tau). The jet is collimated by the magnetic field forming a quasi-stationary shock at the base which emits in X-rays even when perturbations formed by a train of blobs are present. We found similar collimation mechanisms dominating in both heavy and light jets. Conclusions. We derived the pysical parameters that can give rise to X-ray emission consistent with observations of HH 154 and DG Tau. We have also performed a wide exploration of the parameter space characterizing the model; this can represent a useful tool to study and diagnose the physical properties of YSO jets over a broad range of physical conditions, from embedded to disk-bearing sources. We have shown that luminosity did not change significantly in variable jet models for the range of parameters explored. Finally, we provided an estimation of the maximum perturbations that can be present in HH 154 and DG Tau taking into account the available X-ray observations.