From your explanation in the comment, I conclude that your question is about speculation strategies on finance markets. This is off-topic on CV, but allow me to answer nevertheless.
Speculation strategies on finance markets have been analyzed in great detail by Stephan Schulmeister. For a summary, see
Schulmeister: "Short-term Asset Trading, long-term Price Swings, and the Stabilizing Potential of a Transactions Tax." IMF Seminar, Nov 2010
Beware that these strategies are in direct contradiction to "efficient market theory" and are one of the reasons of finance market instability.
Schulmeister gives a gentle introduction in chapter 9 of his book "Der Weg zur Prosperität" (2018, ecowin), which puts these strategies in a broader context and also discusses the obvious question who actually pays the gains achieved with these strategies.
Edit: From your comment below, it is still unclear what your criterion actually is, that is to be maximized, and the question ist thus still unanswerable. The general apporach will be:
- Define your criterion $J$ that is to be maximized.
- Derive a formula for computing $J(T)$, i.e., how $J$ is computed when the parameter $T$ and the emirical distribution is given.
- Use or find some algorithm for finding $arg max\{J(T)\}$.
As your criterion only seems to be a scalar value (the threshold $T$), a simple algorithm for finding the maximum is golden section search.