Profit Maximizer

The Profit Maximizer (PMax) by Kivanc Ozbilgic applies the trailing logic of the Supertrend to a moving average instead of the price. Its two stops lie a multiple of the Average True Range below and above an exponential moving average of the median price, and the trend turns when the average, not the price, crosses a stop. Because the average is smoother than the price, PMax flips less often than the Supertrend and holds a position through short pullbacks.

The formula for the Profit Maximizer starts from the average, the exponential moving average of the median price over the last n periods:

\[\text{Average} = \text{EMA}\left(\frac{\text{High} + \text{Low}}{2}, n\right)\]

The basic stops lie k Average True Ranges over the last a periods below and above that average, the Average True Range being Wilder’s moving average of the True Range, the largest of the period’s range and the distances of its high and low from the previous close:

\[\text{Basic Long Stop} = \text{Average} - k \cdot \text{ATR}(a)\] \[\text{Basic Short Stop} = \text{Average} + k \cdot \text{ATR}(a)\]

The long stop is never lowered while the average stays above the previous long stop, and the short stop never raised while the average stays below the previous short stop; once the average crosses a stop, that stop restarts at its basic level:

\[\text{Long Stop} = \max\left(\text{Basic Long Stop}, \text{Long Stop}_{t-1}\right) \quad \text{if } \text{Average} > \text{Long Stop}_{t-1}\] \[\text{Long Stop} = \text{Basic Long Stop} \quad \text{if } \text{Average} \leq \text{Long Stop}_{t-1}\] \[\text{Short Stop} = \min\left(\text{Basic Short Stop}, \text{Short Stop}_{t-1}\right) \quad \text{if } \text{Average} < \text{Short Stop}_{t-1}\] \[\text{Short Stop} = \text{Basic Short Stop} \quad \text{if } \text{Average} \geq \text{Short Stop}_{t-1}\]

The trend turns down when the average falls below the previous long stop and up when it rises above the previous short stop. PMax is the active stop, the long stop in an uptrend and the short stop in a downtrend:

\[\text{PMax} = \text{Long Stop} \quad \text{if } \text{Trend} = 1\] \[\text{PMax} = \text{Short Stop} \quad \text{if } \text{Trend} = -1\]

A cross of the average above PMax is read as a buy signal and below it as a sell signal. Since the average lags the price, the flips come later than those of the Supertrend, and the stop sits further from the price after a fast move.

The stop is a multiple of the Average True Range away from the price (the median price for the Supertrend, the close for the ATR Trailing Stop), or for the Profit Maximizer from its moving average.

Also known as: PMax.

In the Finance Toolkit this is get_supertrend with method="profit_maximizer", the same function as Supertrend.

Example · SHOP · 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_supertrend:

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["SHOP"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2025-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_supertrend(method="profit_maximizer").xs("SHOP", level=1, axis="columns")

Which returns:

References

  • Paper Ozbilgic, K. (2020). “Profit Maximizer - PMax.” TradingView script.
  • Library Shares similar logic as pandas-ta-classic’s pmax (Profit Maximizer)
Share