An increasing attention is being payed to the scaling behaviour of stock returns. Several reasons motivate this interest: the assumption of self-affinity is implicit both in the standard financial theory (which states that the self-affinity parameter H equals 1/2) and in less consolidate frameworks, such as the fractal gaussian models (for whom H belongs to the interval (0,1)). The scaling structure of prices is usually deduced by analysing the sample moments, but this approach could be misleading because of many reasons, the most ''embarassing'' one being the assumption of existence of the considered moments. Since self-affinity allows to distinguish between two large classes of processes (the fractal - uniscaling - ones and the multifractal - multiscaling - ones), both suggested as models in finance, we reformulate this notion by means of an equivalent definition based on a distance built on the set of the rescaled probability distribution functions generated by the scaling law which defines the notion of self-affinity itself. A general characterization of our measure provides two necessary conditions of self-affinity: monotonicity with respect to both the parameter H and the maximum lag of an increasing sequence of trading horizon sets. We also give the closed expression of our measure when the process is the fractional brownian motion. Furthermore, a proper choice of the metric allows to apply the well-known Kolmogorov-Smirnov goodness of fit test in order to evaluate the statistical significance of the self-affinity measure, also in the case of dependent data whenever uniscaling holds. Finally, an empirical analysis is performed on several market indices. The analysis shows that, for the considered horizons (from one up to fifty trading days), uniscaling does not generally hold in financial markets.