Processing an ECG signal with a median filter
You are certainly doing something very wrong. You should upload your data in order to get better responses. You can upload your data into any upload sites you wish and provide its link here, practically.

Median filter is a highly highly nonlinear filter (it re-orders the sample positions!). The output of the median filter at a position $n$ is the median of the values that reside in the window scope; i.e., it's the value that resides in the middle when the samples are sorted in order. Hence median filtering requires sorting for each computation. This makes it quite slow as well (a deailed answer actually depends on the architecture...) 

Median filter is mainly used for speckle or salt and pepper noise removal, in essence these are local noise samples whose frequency domain filtering is not possible without degrading the whole signal. Such local (in time) peaks will have wide band frequency spectrums which inhibit frequency domain attacks to remove them, therefore, leaving only the time domain (or time-frequency domain) approaches possible.

Median filter has a tendency to preserve edges, therefore quite preferred in certain image enhancement operations. However it also has the side effect of washed out results (texture details are lost and only strong edges remain) which indicates that their use should be performed with care. 

In principle, the longer the window size, the stronger will be the washed out effect. So it's customary to use as short as possible window sizes (unless otherwise dictated by the particular application)

Coming to your example plot. Using a window size larger than 50 samples will wash out local details that might be important to you, so you should use a window size less than 50, I guess (based on the plot you provided).