Is there any algorithm to calculate highest possible return on a stock market? I don't mean the algorithm which trades without mistakes - it's nearly impossible. What I'm searching for is a formula to calculate how much one can gain if he or she would have perfect timing on a stock market. Something which can give us point of reference for effectiveness of our trading strategies.

No leverage, no options, just plain buying and selling stocks of particular company on any possible market. It's not question about strategy, it's a question about calculating highest possible return if we always buy on the lowest price and sell on the highest (taking into account some granularity).

  • 2
    here's the algorithm: 42 – Max Li Jul 18 '15 at 10:09
  • What does "a stock market"? The S&P 500? The US market? Other? A given stock? And with what trading frequency? I can look at a stock or index daily return easy enough, and then assume I was short on down days. I'm sure that would result in a pretty meaninglessly high return. But there's also volatility with a day which can inflate this effect 10 fold. – JoeTaxpayer Jul 18 '15 at 11:26
  • @JoeTaxpayer By saying stock market I mean any particular stock on any stock market. Trading frequency - as high as possible. No leverage. It would be great if algorithm considers broker fees. – Landeeyo Jul 18 '15 at 11:33
  • 1
    @Landeeyo The return of timing every minute of thousands of stocks is still infinity. – base64 Jul 18 '15 at 11:45
  • 2
    @Landeeyo I would suggest you to think over what you want to achieve. You asked this question on here and Programming.SE. You appear to be trying to compare the "effectiveness" of your proprietary strategy. Yet you are reinventing the wheel saying that the absolute change of a single stock is the "benchmark". The industry standard is to use Risk Adjusted Broad Market Index. Numerous people have told you that the maximum single stock return is either infinity or meaningless. You insist on calculating meaningless return that is not accepted for performance track record when presenting your firm. – base64 Jul 18 '15 at 13:40

Highest possible is meaningless.

Ex: Use 17x Leverage on E-mini S&P 500 Futures, perfectly long before an uptick and short before a downtick every minute. Goes to the moon in a day of 1,440 minutes.

You are supposed to use a Buy-and-Hold SPY, with leverage that makes the Standard Deviation of SPY same as your Portfolio/Algorithm, as benchmark.


You can statistically estimate the maximal loss/gain over a period of time T by the highest loss/gain during any of the same length time intervals in during the life of the stock. Using logarithmic prices to be more accurate.


Check this for reference: https://www.geeksforgeeks.org/stock-buy-sell/ It finds optimal if you know the future You can use this algorithm to compare your already taken strategies to the optimal one


To maximize your returns on any given stock without leverage (i.e., without borrowing, shorting), you need to have 100% of your money invested immediately prior to any uptick, and 0% invested prior to any given downtick. The net effect of this (the algorithm) is to discard all downticks and

  1. normalize the gain of all upticks as (priceAfterUptick/priceBeforeUptick)
  2. multiply all the gains together to get your total return.
  • 1
    @RonJohn You don't seem to have read the question. Question: how can I tell what would have been the returns if I had picked an optimal strategy. This isn't a proposed strategy for investing. It's a proposal to measure investing. – Brythan Jan 19 '18 at 22:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .