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")
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The time period to consider for historical data. Options are: “intraday” (intraday prices), “daily” (daily prices), “weekly” (weekly prices), “monthly” (monthly prices), “quarterly” (quarterly prices), “yearly” (yearly prices). Defaults to “daily”. | "weekly" |
close_column | str | The column name for closing prices in the historical data. Defaults to “Adj Close”, in which case the open, high and low prices are adjusted for dividends in the same way. | "Close" |
window | int | Number of periods for the underlying Average True Range calculation, and with method=”profit_maximizer” of the EMA of the median price. Defaults to 10, as defined by Ozbilgic for the Profit Maximizer. | 20 |
multiplier | float | Multiplier applied to the Average True Range to determine how far the bands (or the stops of the Profit Maximizer) sit from the median price (or its average). Defaults to 3.0. | 2.0 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the Supertrend and Trend Direction values. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |
method | str | Options are: “standard” (Supertrend), “profit_maximizer” (Profit Maximizer, PMax), “atr_trailing_stop” (ATR Trailing Stop). Defaults to “standard”. | "standard" |
atr_window | int | The number of periods of the Average True Range of the Profit Maximizer. Only used when method=”profit_maximizer”. Defaults to 10, as defined by Ozbilgic. | 10 |
transform | str | list[str] | None | Time series steps applied in order, such as “sma:12” (moving average), “ema:12”, “std:12”, “zscore:60”, “percentile:120”, “yoy”, “pct_change:3,annualize:3”, “log”, “diff”, “cumsum” or “hp_trend” and “hp_cycle” (Hodrick-Prescott), before growth. A window needs that many periods of history, so the first periods can be empty. Defaults to None. | None |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
Which returns:
| Date | PMax | Trend Direction |
|---|---|---|
| 2025-01-02 | 103.3810 | 1 |
| 2025-01-03 | 103.3810 | 1 |
| 2025-01-06 | 103.3810 | 1 |
| 2025-01-07 | 103.3810 | 1 |
| 2025-01-08 | 103.3810 | 1 |
| 2025-01-10 | 103.3810 | 1 |
| 2025-01-13 | 103.3810 | 1 |
| 2025-01-14 | 103.3810 | 1 |
| 2025-01-15 | 103.3810 | 1 |
| 2025-01-16 | 103.3810 | 1 |
| 2025-01-17 | 103.3810 | 1 |
| 2025-01-21 | 103.3810 | 1 |
| 2025-01-22 | 103.3810 | 1 |
| 2025-01-23 | 103.3810 | 1 |
| 2025-01-24 | 103.3810 | 1 |
| 2025-01-27 | 103.3810 | 1 |
| 2025-01-28 | 103.3810 | 1 |
| 2025-01-29 | 103.3810 | 1 |
| 2025-01-30 | 103.3810 | 1 |
| 2025-01-31 | 103.3810 | 1 |
| 2025-02-03 | 103.3810 | 1 |
| 2025-02-04 | 103.3810 | 1 |
| 2025-02-05 | 103.3810 | 1 |
| 2025-02-06 | 103.3810 | 1 |
| 2025-02-07 | 103.3810 | 1 |
| 2025-02-10 | 103.3810 | 1 |
| 2025-02-11 | 103.3810 | 1 |
| 2025-02-12 | 103.3810 | 1 |
| 2025-02-13 | 103.3810 | 1 |
| 2025-02-14 | 103.4190 | 1 |
| 2025-02-18 | 104.7240 | 1 |
| 2025-02-19 | 105.8760 | 1 |
| 2025-02-20 | 105.8760 | 1 |
| 2025-02-21 | 105.8760 | 1 |
| 2025-02-24 | 105.8760 | 1 |
| 2025-02-25 | 105.8760 | 1 |
| 2025-02-26 | 105.8760 | 1 |
| 2025-02-27 | 105.8760 | 1 |
| 2025-02-28 | 105.8760 | 1 |
| 2025-03-03 | 105.8760 | 1 |
| 2025-03-04 | 105.8760 | 1 |
| 2025-03-05 | 105.8760 | 1 |
| 2025-03-06 | 105.8760 | 1 |
| 2025-03-07 | 105.8760 | 1 |
| 2025-03-10 | 126.1980 | -1 |
| 2025-03-11 | 123.0820 | -1 |
| 2025-03-12 | 121.8660 | -1 |
| 2025-03-13 | 120.3450 | -1 |
| 2025-03-14 | 118.8510 | -1 |
| 2025-03-17 | 117.5500 | -1 |
| 2025-03-18 | 116.0070 | -1 |
| 2025-03-19 | 116.0070 | -1 |
| 2025-03-20 | 116.0070 | -1 |
| 2025-03-21 | 116.0070 | -1 |
| 2025-03-24 | 116.0070 | -1 |
| 2025-03-25 | 116.0070 | -1 |
| 2025-03-26 | 116.0070 | -1 |
| 2025-03-27 | 116.0070 | -1 |
| 2025-03-28 | 116.0070 | -1 |
| 2025-03-31 | 116.0070 | -1 |
| 2025-04-01 | 116.0070 | -1 |
| 2025-04-02 | 116.0070 | -1 |
| 2025-04-03 | 116.0070 | -1 |
| 2025-04-04 | 116.0070 | -1 |
| 2025-04-07 | 115.0770 | -1 |
| 2025-04-08 | 114.2570 | -1 |
| 2025-04-09 | 114.2570 | -1 |
| 2025-04-10 | 114.2570 | -1 |
| 2025-04-11 | 114.2570 | -1 |
| 2025-04-14 | 113.4730 | -1 |
| 2025-04-15 | 111.0800 | -1 |
| 2025-04-16 | 109.3520 | -1 |
| 2025-04-17 | 107.6120 | -1 |
| 2025-04-21 | 105.7750 | -1 |
| 2025-04-22 | 105.0990 | -1 |
| 2025-04-23 | 105.0990 | -1 |
| 2025-04-24 | 105.0990 | -1 |
| 2025-04-25 | 105.0990 | -1 |
| 2025-04-28 | 105.0990 | -1 |
| 2025-04-29 | 105.0990 | -1 |
| 2025-04-30 | 105.0990 | -1 |
| 2025-05-01 | 105.0990 | -1 |
| 2025-05-02 | 105.0990 | -1 |
| 2025-05-05 | 105.0990 | -1 |
| 2025-05-06 | 105.0990 | -1 |
| 2025-05-07 | 105.0990 | -1 |
| 2025-05-08 | 105.0990 | -1 |
| 2025-05-09 | 105.0990 | -1 |
| 2025-05-12 | 105.0990 | -1 |
| 2025-05-13 | 105.0990 | -1 |
| 2025-05-14 | 105.0990 | -1 |
| 2025-05-15 | 105.0990 | -1 |
| 2025-05-16 | 105.0990 | -1 |
| 2025-05-19 | 105.0990 | -1 |
| 2025-05-20 | 105.0990 | -1 |
| 2025-05-21 | 105.0990 | -1 |
| 2025-05-22 | 105.0990 | -1 |
| 2025-05-23 | 105.0990 | -1 |
| 2025-05-27 | 105.0990 | -1 |
| 2025-05-28 | 105.0990 | -1 |
| 2025-05-29 | 91.8953 | 1 |
| 2025-05-30 | 92.1772 | 1 |
| 2025-06-02 | 92.4294 | 1 |
| 2025-06-03 | 93.0402 | 1 |
| 2025-06-04 | 93.1821 | 1 |
| 2025-06-05 | 93.2720 | 1 |
| 2025-06-06 | 93.2720 | 1 |
| 2025-06-09 | 93.9204 | 1 |
| 2025-06-10 | 94.6447 | 1 |
| 2025-06-11 | 95.0808 | 1 |
| 2025-06-12 | 95.3519 | 1 |
| 2025-06-13 | 95.3519 | 1 |
| 2025-06-16 | 95.3519 | 1 |
| 2025-06-17 | 95.4099 | 1 |
| 2025-06-18 | 95.6643 | 1 |
| 2025-06-20 | 95.7888 | 1 |
| 2025-06-23 | 95.7888 | 1 |
| 2025-06-24 | 95.7888 | 1 |
| 2025-06-25 | 97.4828 | 1 |
| 2025-06-26 | 97.4828 | 1 |
| 2025-06-27 | 98.2598 | 1 |
| 2025-06-30 | 99.4661 | 1 |
| 2025-07-01 | 99.9355 | 1 |
| 2025-07-02 | 99.9826 | 1 |
| 2025-07-03 | 101.1150 | 1 |
| 2025-07-07 | 102.1870 | 1 |
| 2025-07-08 | 102.1870 | 1 |
| 2025-07-09 | 102.1870 | 1 |
| 2025-07-10 | 102.1870 | 1 |
| 2025-07-11 | 102.1870 | 1 |
| 2025-07-14 | 102.1870 | 1 |
| 2025-07-15 | 102.1870 | 1 |
| 2025-07-16 | 102.1870 | 1 |
| 2025-07-17 | 102.1870 | 1 |
| 2025-07-18 | 104.1910 | 1 |
| 2025-07-21 | 106.5340 | 1 |
| 2025-07-22 | 106.9870 | 1 |
| 2025-07-23 | 106.9870 | 1 |
| 2025-07-24 | 107.8340 | 1 |
| 2025-07-25 | 108.4150 | 1 |
| 2025-07-28 | 109.5950 | 1 |
| 2025-07-29 | 110.1120 | 1 |
| 2025-07-30 | 110.4490 | 1 |
| 2025-07-31 | 110.5610 | 1 |
| 2025-08-01 | 110.5610 | 1 |
| 2025-08-04 | 110.5610 | 1 |
| 2025-08-05 | 110.5610 | 1 |
| 2025-08-06 | 110.5610 | 1 |
| 2025-08-07 | 110.5610 | 1 |
| 2025-08-08 | 114.6970 | 1 |
| 2025-08-11 | 117.6310 | 1 |
| 2025-08-12 | 120.5450 | 1 |
| 2025-08-13 | 123.3220 | 1 |
| 2025-08-14 | 123.7220 | 1 |
| 2025-08-15 | 124.3170 | 1 |
| 2025-08-18 | 124.9880 | 1 |
| 2025-08-19 | 124.9880 | 1 |
| 2025-08-20 | 124.9880 | 1 |
| 2025-08-21 | 124.9880 | 1 |
| 2025-08-22 | 124.9880 | 1 |
| 2025-08-25 | 124.9880 | 1 |
| 2025-08-26 | 125.0990 | 1 |
| 2025-08-27 | 125.0990 | 1 |
| 2025-08-28 | 125.5980 | 1 |
| 2025-08-29 | 126.3030 | 1 |
| 2025-09-02 | 126.3030 | 1 |
| 2025-09-03 | 126.3030 | 1 |
| 2025-09-04 | 126.3030 | 1 |
| 2025-09-05 | 127.1880 | 1 |
| 2025-09-08 | 128.1470 | 1 |
| 2025-09-09 | 128.8670 | 1 |
| 2025-09-10 | 129.1150 | 1 |
| 2025-09-11 | 129.3040 | 1 |
| 2025-09-12 | 129.6150 | 1 |
| 2025-09-15 | 129.8070 | 1 |
| 2025-09-16 | 130.4370 | 1 |
| 2025-09-17 | 131.2330 | 1 |
| 2025-09-18 | 132.1120 | 1 |
| 2025-09-19 | 133.8470 | 1 |
| 2025-09-22 | 134.5080 | 1 |
| 2025-09-23 | 134.5080 | 1 |
| 2025-09-24 | 134.7540 | 1 |
| 2025-09-25 | 134.7540 | 1 |
| 2025-09-26 | 134.7540 | 1 |
| 2025-09-29 | 134.7540 | 1 |
| 2025-09-30 | 134.7540 | 1 |
| 2025-10-01 | 134.7540 | 1 |
| 2025-10-02 | 134.7540 | 1 |
| 2025-10-03 | 134.7540 | 1 |
| 2025-10-06 | 134.7540 | 1 |
| 2025-10-07 | 135.6980 | 1 |
| 2025-10-08 | 137.6290 | 1 |
| 2025-10-09 | 139.5080 | 1 |
| 2025-10-10 | 139.5080 | 1 |
| 2025-10-13 | 139.5080 | 1 |
| 2025-10-14 | 139.5080 | 1 |
| 2025-10-15 | 139.5080 | 1 |
| 2025-10-16 | 139.5080 | 1 |
| 2025-10-17 | 139.5080 | 1 |
| 2025-10-20 | 139.5080 | 1 |
| 2025-10-21 | 139.5080 | 1 |
| 2025-10-22 | 140.0690 | 1 |
| 2025-10-23 | 141.3180 | 1 |
| 2025-10-24 | 142.9640 | 1 |
| 2025-10-27 | 145.8890 | 1 |
| 2025-10-28 | 147.8300 | 1 |
| 2025-10-29 | 150.2310 | 1 |
| 2025-10-30 | 151.3880 | 1 |
| 2025-10-31 | 151.8560 | 1 |
| 2025-11-03 | 151.8560 | 1 |
| 2025-11-04 | 151.8560 | 1 |
| 2025-11-05 | 151.8560 | 1 |
| 2025-11-06 | 151.8560 | 1 |
| 2025-11-07 | 151.8560 | 1 |
| 2025-11-10 | 151.8560 | 1 |
| 2025-11-11 | 151.8560 | 1 |
| 2025-11-12 | 151.8560 | 1 |
| 2025-11-13 | 151.8560 | 1 |
| 2025-11-14 | 151.8560 | 1 |
| 2025-11-17 | 151.8560 | 1 |
| 2025-11-18 | 174.0230 | -1 |
| 2025-11-19 | 172.4880 | -1 |
| 2025-11-20 | 172.4880 | -1 |
| 2025-11-21 | 172.4880 | -1 |
| 2025-11-24 | 172.4880 | -1 |
| 2025-11-25 | 172.4880 | -1 |
| 2025-11-26 | 172.4880 | -1 |
| 2025-11-28 | 172.4880 | -1 |
| 2025-12-01 | 172.4880 | -1 |
| 2025-12-02 | 172.4880 | -1 |
| 2025-12-03 | 172.4880 | -1 |
| 2025-12-04 | 172.4880 | -1 |
| 2025-12-05 | 172.4880 | -1 |
| 2025-12-08 | 172.4880 | -1 |
| 2025-12-09 | 172.4880 | -1 |
| 2025-12-10 | 172.4880 | -1 |
| 2025-12-11 | 172.4880 | -1 |
| 2025-12-12 | 172.4880 | -1 |
| 2025-12-15 | 172.4880 | -1 |
| 2025-12-16 | 172.4880 | -1 |
| 2025-12-17 | 172.4880 | -1 |
| 2025-12-18 | 172.4880 | -1 |
| 2025-12-19 | 172.4880 | -1 |
| 2025-12-22 | 172.4880 | -1 |
| 2025-12-23 | 172.4880 | -1 |
| 2025-12-24 | 172.4880 | -1 |
| 2025-12-26 | 172.4880 | -1 |
| 2025-12-29 | 172.4880 | -1 |
| 2025-12-30 | 172.4880 | -1 |
| 2025-12-31 | 172.4880 | -1 |
250 rows
References
- Paper Ozbilgic, K. (2020). “Profit Maximizer - PMax.” TradingView script.
- Library Shares similar logic as pandas-ta-classic’s pmax (Profit Maximizer)