There is no continuous function $f$ so that $\int_a^b f(x)x^n dx$, $0\leq a<b$ is positive for all even $n$ and negative for odd $n$
For $n \in \mathbb N$ we have that $$\sigma_n(x) = \frac {x^n \exp(-x)}{n!}$$ is a unimodular probability density function on $\mathbb R_{\geq 0}$ with expectation and variance both equal to $n+1$. Let $\alpha \in (a,b)$ then $$\sigma_n(\alpha; x) = \frac {n+1}{\alpha} \sigma_n\left(\frac {(n+1) x}{\alpha}\right)$$ has expectation $\alpha$ and variance $\alpha^2/(n+1)$. This means that for $n \to \infty$ these functions will have an ever narrower, high peak at $x=\alpha$ and tend uniformly to zero at any given minimal distance from $\alpha$. (Loosely speaking, they tend to the distribution $\delta(x - \alpha)$.)
Now the coefficients of the series for $\exp(-x)$ have alternating signs. Therefore the integral $$I_n(\alpha) = \int_a^b f(x) \sigma_n(\alpha; x) \mathrm dx$$ is positive for even $n$ and negative for odd $n$. But $\lim_{n \to \infty} I_n(\alpha) = f(\alpha)$ so $f$ must be identically zero on $[a, b]$. But then $f$ then doesn’t satisfy its requirements.