Let $P$ be the space of all real monic polynomials of degree $n$; it is isomorphic to $\mathbb{R}^n$. There is a hypersurface $\Delta$ in $P$, cut out by the equation of the discriminant. As you cross $\Delta$, the number of real roots goes up or down by $2$. Also, every time you cross $\Delta$, the discriminant switches signs.

When $n$ is $2$ or $3$, then $P \setminus \Delta$ only has two connected components. On one of these components, all roots are real, and on the other two roots are imaginary. So you can tell which component you are in just be looking at the sign of the discriminant. Once $n$ is $4$ or larger, there are more than two connected components to $P \setminus \Delta$. So the sign of the discriminant can't tell you which component you are in. I don't know a formula for the number of connected components of $P \setminus \Delta$, but one could be extracted from the description of the toplogy of $(P, \Delta)$ in Gelfand, Kapranov and Zelevinsky, *Discriminants, Resultants and Multidimensional Determinants*.

One way to interpret your question is

Is there a polynomial $F$ on $P$ which is positive on the polynomials with $n$ real roots, and negative otherwise?

The answer is "no". The variety $\Delta$ is irreducible (by the Horn uniformization). By a standard lemma, any nonempty open subset of the real points of $\Delta$ is Zariski dense in $\Delta$. So, if $F$ vanishes on the part of $\Delta$ which forms the boundary of {Polynomials with all roots real}, then $F$ also vanishes on all of $\Delta$. Working a little harder, we can show that if $F$ vanishes to odd order on the boundary of {Polynomials with all roots real}, then it also vanishes to odd order on the other connected components of $\Delta(\mathbb{R})$.

On the other hand, there are many good ways to determine the number of real roots by polynomial computations, such as Sturm's method.