Pine Script v4 · Strategy
Strategy - Profit Maximizer by PMax
A Pine Script v4 strategy built on SMA (tr, 10), ATR (10) and EMA (zxEMAData, 10). It has 5 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays 0.025 commission. 18 settings; defaults include Source hl2, ATR Length 10 and ATR Multiplier 3.0.
Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.
- Does Strategy - Profit Maximizer by PMax repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Strategy - Profit Maximizer by PMax do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
- Can Strategy - Profit Maximizer by PMax be converted to Pine Script v5?
- Not tested
- The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
- What alerts does Strategy - Profit Maximizer by PMax have?
- 6
- Cross Alert; Crossover Alarm; Crossunder Alarm; Price Cross Alert; and more.
- Does Strategy - Profit Maximizer by PMax use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
BTCUSDT · 1D · default settings
- Moving Avg Line
- PMax
- Buy
- Sell
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
One run with the author's default settings, $1,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Likely bug
atr(20) ignores the settings line 108
Line 108 hard-codes 20 where line 40 uses “ATR Length”. Changing those settings moves one band but not this one.
atr(20)atr(Periods) -
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Note
Uses transp =, which v5 removed line 99
transp = on line 99, 112, 117, 123, 127. v5 folds the transparency into the colour with color.new(c, transp).
-
Note
Uses long =, which v5 renamed line 114
long = on line 114, 119, 125, 129. v5 writes it as direction = strategy.long or strategy.short.
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames sma → ta.sma, atr → ta.atr, sum → math.sum, abs → math.abs, round → math.round, ema → ta.ema, linreg → ta.linreg, wma → ta.wma, ceil → math.ceil, floor → math.floor, max → math.max, min → math.min, cross → ta.cross, crossover → ta.crossover, crossunder → ta.crossunder.
v4 → v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 1: //@version=4 → //@version=5
- Line 11: input(type = input.integer) → input.int()
- Line 12: input(type = input.float) → input.float()
- Line 15: input(type = input.bool) → input.bool()
- Line 16: input(type = input.bool) → input.bool()
- Line 17: input(type = input.bool) → input.bool()
53 more edits
- Line 18: input(type = input.bool) → input.bool()
- Line 19: input(type = input.bool) → input.bool()
- Line 20: input(type = input.bool) → input.bool()
- Line 21: input(type = input.float) → input.float()
- Line 23: input(type = input.integer) → input.int()
- Line 25: input(type = input.integer) → input.int()
- Line 27: input(type = input.integer) → input.int()
- Line 29: input(type = input.integer) → input.int()
- Line 31: input(type = input.integer) → input.int()
- Line 33: input(type = input.integer) → input.int()
- Line 39: sma → ta.sma
- Line 39: tr → ta.tr
- Line 40: atr → ta.atr
- Line 44: sum → math.sum
- Line 45: sum → math.sum
- Line 48: abs → math.abs
- Line 48: abs → math.abs
- Line 52: round → math.round
- Line 54: ema → ta.ema
- Line 55: linreg → ta.linreg
- Line 56: linreg → ta.linreg
- Line 58: linreg → ta.linreg
- Line 62: sma → ta.sma
- Line 65: ema → ta.ema
- Line 68: wma → ta.wma
- Line 71: sma → ta.sma
- Line 71: sma → ta.sma
- Line 71: ceil → math.ceil
- Line 71: floor → math.floor
- Line 90: max → math.max
- Line 93: min → math.min
- Line 99: transp = 0 → color.new(color.red, 0)
- Line 100: cross → ta.cross
- Line 101: crossover → ta.crossover
- Line 102: crossunder → ta.crossunder
- Line 103: cross → ta.cross
- Line 104: crossover → ta.crossover
- Line 105: crossunder → ta.crossunder
- Line 108: atr → ta.atr
- Line 109: floor → math.floor
- Line 111: crossover → ta.crossover
- Line 112: transp = 0 → color.new(color.green, 0)
- Line 114: long = true → direction = strategy.long
- Line 116: crossunder → ta.crossunder
- Line 117: transp = 0 → color.new(color.red, 0)
- Line 119: long = false → direction = strategy.short
- Line 122: crossover → ta.crossover
- Line 123: transp = 0 → color.new(#0F18BF, 0)
- Line 125: long = false → direction = strategy.short
- Line 126: crossunder → ta.crossunder
- Line 127: transp = 0 → color.new(#0F18BF, 0)
- Line 129: long = true → direction = strategy.long
- Line 129: abs → math.abs
-//@version=4+//@version=5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯src = input(hl2, title="Source")-Periods = input(title="ATR Length", type=input.integer, defval=10)+Periods = input.int(title="ATR Length", defval=10)-Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)+Multiplier = input.float(title="ATR Multiplier", step=0.1, defval=3.0)mav = input(title="Moving Average Type", defval="ZLEMA", options=["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"])length =input(10, "Moving Average Length", minval=1)-changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)+changeATR= input.bool(title="Change ATR Calculation Method ?", defval=true)-showsupport = input(title="Show Moving Average?", type=input.bool, defval=true)+showsupport = input.bool(title="Show Moving Average?", defval=true)-showsignalsk = input(title="Show Crossing Signals?", type=input.bool, defval=true)+showsignalsk = input.bool(title="Show Crossing Signals?", defval=true)-showsignalsc = input(title="Show Price/Pmax Crossing Signals?", type=input.bool, defval=false)+showsignalsc = input.bool(title="Show Price/Pmax Crossing Signals?", defval=false)-highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)+highlighting = input.bool(title="Highlighter On/Off ?", defval=true)-usePosSize = input(title="Use Position Sizing?", type=input.bool, defval=true)+usePosSize = input.bool(title="Use Position Sizing?", defval=true)-riskPerc = input(title="Risk %", type=input.float, defval=0.5, step=0.25)+riskPerc = input.float(title="Risk %", defval=0.5, step=0.25)// Make input options that configure backtest date range-startDate = input(title="Start Date", type=input.integer,+startDate = input.int(title="Start Date", defval=1, minval=1, maxval=31)-startMonth = input(title="Start Month", type=input.integer,+startMonth = input.int(title="Start Month", defval=1, minval=1, maxval=12)-startYear = input(title="Start Year", type=input.integer,+startYear = input.int(title="Start Year", defval=2019, minval=1800, maxval=2100)-endDate = input(title="End Date", type=input.integer,+endDate = input.int(title="End Date", defval=1, minval=1, maxval=31)-endMonth = input(title="End Month", type=input.integer,+endMonth = input.int(title="End Month", defval=12, minval=1, maxval=12)-endYear = input(title="End Year", type=input.integer,+endYear = input.int(title="End Year", defval=2021, minval=1800, maxval=2100)⋯inDateRange = (time >= timestamp(syminfo.timezone, startYear,startMonth, startDate, 0, 0)) and (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))-atr2 = sma(tr, Periods)+atr2 = ta.sma(ta.tr, Periods)-atr= changeATR ? atr(Periods) : atr2+atr= changeATR ? ta.atr(Periods) : atr2valpha=2/(length+1)⋯vdd1=src<src[1] ? src[1]-src : 0-vUD=sum(vud1,9)+vUD=math.sum(vud1,9)-vDD=sum(vdd1,9)+vDD=math.sum(vdd1,9)vCMO=nz((vUD-vDD)/(vUD+vDD))VAR=0.0-VAR:=nz(valpha*abs(vCMO)*src)+(1-valpha*abs(vCMO))*nz(VAR[1])+VAR:=nz(valpha*math.abs(vCMO)*src)+(1-valpha*math.abs(vCMO))*nz(VAR[1])wwalpha = 1/ length⋯WWMA := wwalpha*src + (1-wwalpha)*nz(WWMA[1])-zxLag = length/2==round(length/2) ? length/2 : (length - 1) / 2+zxLag = length/2==math.round(length/2) ? length/2 : (length - 1) / 2zxEMAData = (src + (src - src[zxLag]))-ZLEMA = ema(zxEMAData, length)+ZLEMA = ta.ema(zxEMAData, length)-lrc = linreg(src, length, 0)+lrc = ta.linreg(src, length, 0)-lrc1 = linreg(src,length,1)+lrc1 = ta.linreg(src,length,1)lrs = (lrc-lrc1)-TSF = linreg(src, length, 0)+lrs+TSF = ta.linreg(src, length, 0)+lrsgetMA(src, length) =>⋯ if mav == "SMA"- ma := sma(src, length)+ ma := ta.sma(src, length) ma if mav == "EMA"- ma := ema(src, length)+ ma := ta.ema(src, length) ma if mav == "WMA"- ma := wma(src, length)+ ma := ta.wma(src, length) ma if mav == "TMA"- ma := sma(sma(src, ceil(length / 2)), floor(length / 2) + 1)+ ma := ta.sma(ta.sma(src, math.ceil(length / 2)), math.floor(length / 2) + 1) ma⋯longStopPrev = nz(longStop[1], longStop)-longStop := MAvg > longStopPrev ? max(longStop, longStopPrev) : longStop+longStop := MAvg > longStopPrev ? math.max(longStop, longStopPrev) : longStopshortStop = MAvg + Multiplier*atrshortStopPrev = nz(shortStop[1], shortStop)-shortStop := MAvg < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop+shortStop := MAvg < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStopdir = 1⋯plot(showsupport ? MAvg : na, color=#0585E1, linewidth=2, title="Moving Avg Line")-pALL=plot(PMax, color=color.red, linewidth=2, title="PMax", transp=0)+pALL=plot(PMax, color=color.new(color.red, 0), linewidth=2, title="PMax")-alertcondition(cross(MAvg, PMax), title="Cross Alert", message="PMax - Moving Avg Crossing!")+alertcondition(ta.cross(MAvg, PMax), title="Cross Alert", message="PMax - Moving Avg Crossing!")-alertcondition(crossover(MAvg, PMax), title="Crossover Alarm", message="Moving Avg BUY SIGNAL!")+alertcondition(ta.crossover(MAvg, PMax), title="Crossover Alarm", message="Moving Avg BUY SIGNAL!")-alertcondition(crossunder(MAvg, PMax), title="Crossunder Alarm", message="Moving Avg SELL SIGNAL!")+alertcondition(ta.crossunder(MAvg, PMax), title="Crossunder Alarm", message="Moving Avg SELL SIGNAL!")-alertcondition(cross(src, PMax), title="Price Cross Alert", message="PMax - Price Crossing!")+alertcondition(ta.cross(src, PMax), title="Price Cross Alert", message="PMax - Price Crossing!")-alertcondition(crossover(src, PMax), title="Price Crossover Alarm", message="PRICE OVER PMax - BUY SIGNAL!")+alertcondition(ta.crossover(src, PMax), title="Price Crossover Alarm", message="PRICE OVER PMax - BUY SIGNAL!")-alertcondition(crossunder(src, PMax), title="Price Crossunder Alarm", message="PRICE UNDER PMax - SELL SIGNAL!")+alertcondition(ta.crossunder(src, PMax), title="Price Crossunder Alarm", message="PRICE UNDER PMax - SELL SIGNAL!")// Calculate position sizeriskEquity = (riskPerc / 100) * strategy.equity-atrCurrency = (atr(20) * syminfo.pointvalue)+atrCurrency = (ta.atr(20) * syminfo.pointvalue)-posSize = usePosSize ? floor(riskEquity / atrCurrency) : 1+posSize = usePosSize ? math.floor(riskEquity / atrCurrency) : 1//Long-buySignalk = crossover(MAvg, PMax)+buySignalk = ta.crossover(MAvg, PMax)-plotshape(buySignalk and showsignalsk ? PMax*0.995 : na, title="Buy", text="BuyL", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)+plotshape(buySignalk and showsignalsk ? PMax*0.995 : na, title="Buy", text="BuyL", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.white)if(buySignalk and showsignalsk and inDateRange)- strategy.entry(id="buySignalk", long=true, qty=posSize)+ strategy.entry(id="buySignalk", direction = strategy.long, qty=posSize) -sellSignallk = crossunder(MAvg, PMax)+sellSignallk = ta.crossunder(MAvg, PMax)-plotshape(sellSignallk and showsignalsk ? PMax*1.005 : na, title="Sell", text="SellL", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)+plotshape(sellSignallk and showsignalsk ? PMax*1.005 : na, title="Sell", text="SellL", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.white)if(sellSignallk and showsignalsk and inDateRange)- strategy.order(id="sellSignallk", long=false, qty=strategy.position_size)+ strategy.order(id="sellSignallk", direction = strategy.short, qty=strategy.position_size) //Short-buySignalc = crossover(src, PMax)+buySignalc = ta.crossover(src, PMax)-plotshape(buySignalc and showsignalsc ? PMax*0.995 : na, title="Buy", text="BuyS", location=location.absolute, style=shape.labelup, size=size.tiny, color=#0F18BF, textcolor=color.white, transp=0)+plotshape(buySignalc and showsignalsc ? PMax*0.995 : na, title="Buy", text="BuyS", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(#0F18BF, 0), textcolor=color.white)if(buySignalc and showsignalsc and inDateRange)- strategy.entry(id="BuyS", long=false, qty=posSize)+ strategy.entry(id="BuyS", direction = strategy.short, qty=posSize)-sellSignallc = crossunder(src, PMax)+sellSignallc = ta.crossunder(src, PMax)-plotshape(sellSignallc and showsignalsc ? PMax*1.005 : na, title="Sell", text="SellS", location=location.absolute, style=shape.labeldown, size=size.tiny, color=#0F18BF, textcolor=color.white, transp=0)+plotshape(sellSignallc and showsignalsc ? PMax*1.005 : na, title="Sell", text="SellS", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(#0F18BF, 0), textcolor=color.white)if(sellSignallc and showsignalsc and inDateRange)- strategy.order(id="SellS", long=true, qty=abs(strategy.position_size))+ strategy.order(id="SellS", direction = strategy.long, qty=math.abs(strategy.position_size))mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0,display=display.none)⋯Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 10: input() → input.source()
- Line 13: input() → input.string()
- Line 14: input() → input.int()
⋯ commission_value=0.025, slippage=2)-src = input(hl2, title="Source")+src = input.source(hl2, title="Source")Periods = input.int(title="ATR Length", defval=10)Multiplier = input.float(title="ATR Multiplier", step=0.1, defval=3.0)-mav = input(title="Moving Average Type", defval="ZLEMA", options=["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"])+mav = input.string(title="Moving Average Type", defval="ZLEMA", options=["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"])-length =input(10, "Moving Average Length", minval=1)+length =input.int(10, "Moving Average Length", minval=1)changeATR= input.bool(title="Change ATR Calculation Method ?", defval=true)⋯Does it run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L130:C56: 'linewidth' must be at least 1 in Pine Script v6. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
-//@version=5+//@version=6// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Source | hl2 | source | vud1 vdd1 VAR WWMA zxEMAData lrc lrc1 TSF ma MAvg buySignalc sellSignallc Price Cross Alert Price Crossover Alarm Price Crossunder Alarm |
| ATR Length | 10 | int (written input.integer) | atr2 atr |
| ATR Multiplier | 3.0 | float · step 0.1 | longStop shortStop |
| Moving Average Type | ZLEMA | string · options ["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"] | line 61 line 64 line 67 line 70 line 73 line 76 line 79 line 82 |
| Moving Average Length | 10 | int · min 1 | valpha wwalpha zxLag ZLEMA lrc lrc1 TSF ma MAvg |
| Change ATR Calculation Method ? | true | bool | atr |
| Show Moving Average? | true | bool | Moving Avg Line |
| Show Crossing Signals? | true | bool | entry buySignalk order sellSignallk Buy line 113 Sell line 118 |
| Show Price/Pmax Crossing Signals? | false | bool | entry BuyS order SellS Buy line 124 Sell line 128 |
| Highlighter On/Off ? | true | bool | longFillColor shortFillColor |
| Use Position Sizing? | true | bool | posSize |
| Risk % | 0.5 | float · step 0.25 | riskEquity |
| Start Date | 1 | int (written input.integer) · min 1 · max 31 | inDateRange |
| Start Month | 1 | int (written input.integer) · min 1 · max 12 | inDateRange |
| Start Year | 2019 | int (written input.integer) · min 1800 · max 2100 | inDateRange |
| End Date | 1 | int (written input.integer) · min 1 · max 31 | inDateRange |
| End Month | 12 | int (written input.integer) · min 1 · max 12 | inDateRange |
| End Year | 2021 | int (written input.integer) · min 1800 · max 2100 | inDateRange |
What it calculates
- SMA (
sma,ta.smain v5)tr, ATR Length (10)atr2 · line 39 - ATR (
atr,ta.atrin v5)ATR Length (10)atr · line 40 - EMA (
ema,ta.emain v5)zxEMAData, Moving Average Length (10)ZLEMA · line 54 - Linreg (
linreg,ta.linregin v5)Source (hl2), Moving Average Length (10), 0lrc · line 55 - Linreg (
linreg,ta.linregin v5)Source (hl2), Moving Average Length (10), 1lrc1 · line 56 - Linreg (
linreg,ta.linregin v5)Source (hl2), Moving Average Length (10), 0TSF · line 58 - SMA / EMA / WMA (
sma,ta.smain v5)Source (hl2), Moving Average Length (10)ma · line 62 - ATR (
atr,ta.atrin v5)20atrCurrency · line 108 - Crossover (
crossover,ta.crossoverin v5)MAvg, PMaxbuySignalk · line 111 - Crossunder (
crossunder,ta.crossunderin v5)MAvg, PMaxsellSignallk · line 116 - Crossover (
crossover,ta.crossoverin v5)Source (hl2), PMaxbuySignalc · line 122 - Crossunder (
crossunder,ta.crossunderin v5)Source (hl2), PMaxsellSignallc · line 126
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
The script has 66 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open buySignalk long | (buySignalk and showsignalsk and inDateRange) | On | 114 |
| order sellSignallk short | (sellSignallk and showsignalsk and inDateRange) | On | 119 |
| Open BuyS short | (buySignalc and showsignalsc and inDateRange) | On | 125 |
| order SellS long | (sellSignallc and showsignalsc and inDateRange) | On | 129 |
| Close | (not inDateRange) | On | 137 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| Cross Alert | alertcondition | PMax - Moving Avg Crossing! | 100 |
| Crossover Alarm | alertcondition | Moving Avg BUY SIGNAL! | 101 |
| Crossunder Alarm | alertcondition | Moving Avg SELL SIGNAL! | 102 |
| Price Cross Alert | alertcondition | PMax - Price Crossing! | 103 |
| Price Crossover Alarm | alertcondition | PRICE OVER PMax - BUY SIGNAL! | 104 |
| Price Crossunder Alarm | alertcondition | PRICE UNDER PMax - SELL SIGNAL! | 105 |
Does it repaint?
No
No repainting patterns in the source.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Strategy - Profit Maximizer by PMax this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| Profit Maximizer PMax Strategy - Long-Short by melihtuna | sma atr ema linreg | v4 strategy | +16.2% | 4 | 27.8% |
| Open Close Cross Strategy plus Explorer by roses27 | sma ema wma linreg atr | v4 strategy | does not run in Zeal Terminal | ||
| Profit Maximizer Strategy by SoftKill21 | sma atr ema linreg | v4 strategy | −3.6% | 5 | 3.6% |
| Y-Profit Maximizer Strategy with Exit Points by Enes_Yetkin_ | ema sma atr linreg | v4 strategy | −1.9% | 13 | 30.4% |
| Strategy Myth-Busting #2 - Braid Filter+ADX+EMA-Trend - [MYN] by myncrypto | sma ema wma atr | v5 strategy | −47.2% | 4 | 48.6% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 35 ms | With a workaround 1,000 bars in 119 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as long = true, long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 114, 119, 125, 129) so the engine trades the way the script says.
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
//@version=4// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © KivancOzbilgic//developer: @KivancOzbilgic//author: @KivancOzbilgicstrategy(title="Profit Maximizer PMax", overlay=true, pyramiding=0, initial_capital=1000, commission_type=strategy.commission.cash_per_order, commission_value=0.025, slippage=2)src = input(hl2, title="Source")Periods = input(title="ATR Length", type=input.integer, defval=10)Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)mav = input(title="Moving Average Type", defval="ZLEMA", options=["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"])length =input(10, "Moving Average Length", minval=1)changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)showsupport = input(title="Show Moving Average?", type=input.bool, defval=true)showsignalsk = input(title="Show Crossing Signals?", type=input.bool, defval=true)showsignalsc = input(title="Show Price/Pmax Crossing Signals?", type=input.bool, defval=false)highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)usePosSize = input(title="Use Position Sizing?", type=input.bool, defval=true)riskPerc = input(title="Risk %", type=input.float, defval=0.5, step=0.25)// Make input options that configure backtest date rangestartDate = input(title="Start Date", type=input.integer, defval=1, minval=1, maxval=31)startMonth = input(title="Start Month", type=input.integer, defval=1, minval=1, maxval=12)startYear = input(title="Start Year", type=input.integer, defval=2019, minval=1800, maxval=2100)endDate = input(title="End Date", type=input.integer, defval=1, minval=1, maxval=31)endMonth = input(title="End Month", type=input.integer, defval=12, minval=1, maxval=12)endYear = input(title="End Year", type=input.integer, defval=2021, minval=1800, maxval=2100) // Look if the close time of the current bar// falls inside the date rangeinDateRange = (time >= timestamp(syminfo.timezone, startYear,startMonth, startDate, 0, 0)) and (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))atr2 = sma(tr, Periods)atr= changeATR ? atr(Periods) : atr2valpha=2/(length+1)vud1=src>src[1] ? src-src[1] : 0vdd1=src<src[1] ? src[1]-src : 0vUD=sum(vud1,9)vDD=sum(vdd1,9)vCMO=nz((vUD-vDD)/(vUD+vDD))VAR=0.0VAR:=nz(valpha*abs(vCMO)*src)+(1-valpha*abs(vCMO))*nz(VAR[1])wwalpha = 1/ lengthWWMA = 0.0WWMA := wwalpha*src + (1-wwalpha)*nz(WWMA[1])zxLag = length/2==round(length/2) ? length/2 : (length - 1) / 2zxEMAData = (src + (src - src[zxLag]))ZLEMA = ema(zxEMAData, length)lrc = linreg(src, length, 0)lrc1 = linreg(src,length,1)lrs = (lrc-lrc1)TSF = linreg(src, length, 0)+lrsgetMA(src, length) => ma = 0.0 if mav == "SMA" ma := sma(src, length) ma if mav == "EMA" ma := ema(src, length) ma if mav == "WMA" ma := wma(src, length) ma if mav == "TMA" ma := sma(sma(src, ceil(length / 2)), floor(length / 2) + 1) ma if mav == "VAR" ma := VAR ma if mav == "WWMA" ma := WWMA ma if mav == "ZLEMA" ma := ZLEMA ma if mav == "TSF" ma := TSF ma ma MAvg=getMA(src, length)longStop = MAvg - Multiplier*atrlongStopPrev = nz(longStop[1], longStop)longStop := MAvg > longStopPrev ? max(longStop, longStopPrev) : longStopshortStop = MAvg + Multiplier*atrshortStopPrev = nz(shortStop[1], shortStop)shortStop := MAvg < shortStopPrev ? min(shortStop, shortStopPrev) : shortStopdir = 1dir := nz(dir[1], dir)dir := dir == -1 and MAvg > shortStopPrev ? 1 : dir == 1 and MAvg < longStopPrev ? -1 : dirPMax = dir==1 ? longStop: shortStopplot(showsupport ? MAvg : na, color=#0585E1, linewidth=2, title="Moving Avg Line")pALL=plot(PMax, color=color.red, linewidth=2, title="PMax", transp=0)alertcondition(cross(MAvg, PMax), title="Cross Alert", message="PMax - Moving Avg Crossing!")alertcondition(crossover(MAvg, PMax), title="Crossover Alarm", message="Moving Avg BUY SIGNAL!")alertcondition(crossunder(MAvg, PMax), title="Crossunder Alarm", message="Moving Avg SELL SIGNAL!")alertcondition(cross(src, PMax), title="Price Cross Alert", message="PMax - Price Crossing!")alertcondition(crossover(src, PMax), title="Price Crossover Alarm", message="PRICE OVER PMax - BUY SIGNAL!")alertcondition(crossunder(src, PMax), title="Price Crossunder Alarm", message="PRICE UNDER PMax - SELL SIGNAL!")// Calculate position sizeriskEquity = (riskPerc / 100) * strategy.equityatrCurrency = (atr(20) * syminfo.pointvalue)posSize = usePosSize ? floor(riskEquity / atrCurrency) : 1//LongbuySignalk = crossover(MAvg, PMax)plotshape(buySignalk and showsignalsk ? PMax*0.995 : na, title="Buy", text="BuyL", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)if(buySignalk and showsignalsk and inDateRange) strategy.entry(id="buySignalk", long=true, qty=posSize) sellSignallk = crossunder(MAvg, PMax)plotshape(sellSignallk and showsignalsk ? PMax*1.005 : na, title="Sell", text="SellL", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)if(sellSignallk and showsignalsk and inDateRange) strategy.order(id="sellSignallk", long=false, qty=strategy.position_size) //ShortbuySignalc = crossover(src, PMax)plotshape(buySignalc and showsignalsc ? PMax*0.995 : na, title="Buy", text="BuyS", location=location.absolute, style=shape.labelup, size=size.tiny, color=#0F18BF, textcolor=color.white, transp=0)if(buySignalc and showsignalsc and inDateRange) strategy.entry(id="BuyS", long=false, qty=posSize)sellSignallc = crossunder(src, PMax)plotshape(sellSignallc and showsignalsc ? PMax*1.005 : na, title="Sell", text="SellS", location=location.absolute, style=shape.labeldown, size=size.tiny, color=#0F18BF, textcolor=color.white, transp=0)if(sellSignallc and showsignalsc and inDateRange) strategy.order(id="SellS", long=true, qty=abs(strategy.position_size))mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0,display=display.none)longFillColor = highlighting ? (MAvg>PMax ? color.green : na) : nashortFillColor = highlighting ? (MAvg<PMax ? color.red : na) : nafill(mPlot, pALL, title="UpTrend Highligter", color=longFillColor)fill(mPlot, pALL, title="DownTrend Highligter", color=shortFillColor)// Exit open market position when date range endsif (not inDateRange) strategy.close_all()