Bounded $r$- variation function with a dense set of local maximum values This is a sharpening of the following problem: $C^1$ function with a dense set of maximum values.
Problem set up:
Let $f \colon [0, 1] \to \mathbb R$ be a function on the unit interval. We say $y \in \mathbb R$ is a local maximum value of $f$ if $y = f(x)$ for some strict local maximum $x$ of $f$.

Question: Let $r > 1$. Does there exist a function $f$ on the unit interval of bounded $r$-variation such that the set of local maximum values of $f$ is dense in some (nontrivial) open interval $(a, \, b)$?

Remarks:
Note that a $C^0$ example is provided by a Brownian motion sample path, since a Brownian motion almost surely achieves a strict maximum in every interval. In the above problem, it is shown that a $C^1$ function with the above properties cannot exist, and I believe neither can a bounded variation one.
Thus an interesting question to ask is of bounded $r$-variation. The case $r = 1$ is impossible, and $r > 2$ is given by Brownian motion. For which $r$ precisely can this phenomenon occur?
 A: The Takagi function [1], [2] has finite r-variation for all $r>1$. The proof [1] that it is nowhere differentiable also shows that the locations of local maxima are dense in an interval and so are their values.
[1] Takagi, Teiji (1901), "A Simple Example of the Continuous Function without Derivative", Proc. Phys.-Math. Soc. Jpn., 1: 176–177
[2] https://en.wikipedia.org/wiki/Blancmange_curve
A: If you are happy with probabilistic constructions, fractional Brownian motion $X_t^H$ gives an answer. If it's Hurst parameter is $H \in (0, 1)$, then the paths of $X_t^H$ have infinite $1/H$-variation with probability one, and hence they necessarily attain local maxima in a dense set of $t$, just as the usual Brownian motion. On the other hand, the $r$-variation of $X_t^H$ is finite with probability one for every $r > 1/H$, and of course such $r$ can be arbitrarily close to $1$ if one chooses $H$ appropriately.
A sample reference for the above is:

*

*Pratelli M. (2011) A Remark on the $1/H$-Variation of the Fractional Brownian Motion. In: Donati-Martin C., Lejay A., Rouault A. (eds) Séminaire de Probabilités XLIII. Lecture Notes in Mathematics, vol 2006. Springer, Berlin, Heidelberg. DOI:10.1007/978-3-642-15217-7_8
A: I just realised that there is a function of bounded variation — in fact, even a Lipschitz one — that attains local maxima on a dense subset of its domain.
The construction is in fact quite simple. We need a set $A$ such that for every interval $(a, b)$, both $(a, b) \cap A$ and $(a, b) \setminus A$ have positive Lebesgue measure. Then
\[ f(x) = \int_0^x (2 \cdot \mathbb 1_A(s) - 1) ds \]
is clearly a Lipschitz function. Furthermore, for every interval $(a, b)$ there are $x_1 \in (a, \tfrac{a+b}{2})$ and $x_2 \in (\tfrac{a+b}{2}, b)$ such that $f'(x_1) = 1$ and $f'(x_2) = -1$ (indeed: $f'(x) = 1$ for almost all $x \in A$, and $f'(x) = -1$ for almost all $x \notin A$), and therefore $f$ attains a local maximum in $(a, b)$, somewhere between $x_1$ and $x_2$.
The set $A$ can be constructed as follows: let $q_n$ be a sequence of all rationals in $(0, 1)$, let $A_0 = \varnothing$, and define
\[ A_{n+1} = \bigl(A_n \cup (q_n, q_n + \tfrac{1}{3^n})\bigr) \setminus (q_n - \tfrac{1}{3^n}, q_n) . \]
Then $A_{n+1}$ and $A_n$ differ on a set of measure at most $\tfrac{2}{3^n}$, and since this sequence is summable, the limiting set $A = \lim_{n \to \infty} A_n$ is well-defined up to a null set. Finally, it is easy to show that for $k > n$ the sets $(q_n, q_n + \tfrac{1}{3^n}) \cap A_k$ and $(q_n - \tfrac{1}{3^n}, q_n) \setminus A_k$ have measure at least
\[ \tfrac{1}{3^n} - \tfrac{1}{3^{n+1}} - \tfrac{1}{3^{n+1}} - \ldots - \tfrac{1}{3^{k-1}} > \tfrac{1}{2 \cdot 3^n} \]
and consequently both $(q_n, q_n + \tfrac{1}{3^n}) \cap A$ and $(q_n - \tfrac{1}{3^n}, q_n) \setminus A$ have positive measure (at least $\tfrac{1}{2 \cdot 3^n}$). Since every interval $(a, b)$ contains $(q_n - \tfrac{1}{3^n}, q_n + \tfrac{1}{3^n})$ for some $n$, we conclude that $(a, b) \cap A$ and $(a, b) \setminus A$ both have positive measure.
