Time-domain astronomy has emerged as one of the most promising fields in astronomy. Time-frequency analysis methods like Fourier and wavelet transforms are widely used in astronomy but have profound limitations in analysing nonlinear or non-stationary data, which are dominant in natural systems. Hilbert--Huang transform (HHT) has been proven to be an adaptive method without such limitations, but has not been fully applied in astronomy. The major hurdle might be from that HHT is an empirical approach requiring tuneable parameters to be optimised using experimental results or known facts, which are practically more challenging to obtain in astronomy than in other fields. In this work, we propose a parameter-optimised HHT method that can solve this problem by adjusting the orthogonal indices among decomposed components, and successfully apply it to quasi-periodic phenomena from microquasar and solar flare. The HHT results not only match the results from Fourier and wavelet analyses but also provide critical new information with unprecedented frequency and temporal resolutions by HHT's virtues of superior adaptivity and sensitivity to signals. We demonstrate for the first time that some X-ray quasi-periodic oscillations detected using Fourier method are spurious ones, and the X-ray variability can be decomposed into model-independent components. We also obtain the finest evolution of solar quasi-periodic pulsation. These results provide new probes to study the physical processes of accretion flows and solar eruptive events. More importantly, our method is a powerful tool for unveiling the mysteries of the fascinating transient and time-variable phenomena throughout the universe. It is also a leap in application method of HHT and will be beneficial to many other fields.