Zeal Terminal Open in Zeal Terminal

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
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (18)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,000$2,025Equity from $1,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. 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.
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 verified

Neither 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 verified

Neither 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.

SettingDefaultType and rangeFeeds
Sourcehl2sourcevud1 vdd1 VAR WWMA zxEMAData lrc lrc1 TSF ma MAvg buySignalc sellSignallc Price Cross Alert Price Crossover Alarm Price Crossunder Alarm
ATR Length10int (written input.integer)atr2 atr
ATR Multiplier3.0float · step 0.1longStop shortStop
Moving Average TypeZLEMAstring · 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 Length10int · min 1valpha wwalpha zxLag ZLEMA lrc lrc1 TSF ma MAvg
Change ATR Calculation Method ?trueboolatr
Show Moving Average?trueboolMoving Avg Line
Show Crossing Signals?trueboolentry buySignalk order sellSignallk Buy line 113 Sell line 118
Show Price/Pmax Crossing Signals?falseboolentry BuyS order SellS Buy line 124 Sell line 128
Highlighter On/Off ?trueboollongFillColor shortFillColor
Use Position Sizing?trueboolposSize
Risk %0.5float · step 0.25riskEquity
Start Date1int (written input.integer) · min 1 · max 31inDateRange
Start Month1int (written input.integer) · min 1 · max 12inDateRange
Start Year2019int (written input.integer) · min 1800 · max 2100inDateRange
End Date1int (written input.integer) · min 1 · max 31inDateRange
End Month12int (written input.integer) · min 1 · max 12inDateRange
End Year2021int (written input.integer) · min 1800 · max 2100inDateRange

What it calculates

  • SMA (sma, ta.sma in v5)tr, ATR Length (10)atr2 · line 39
  • ATR (atr, ta.atr in v5)ATR Length (10)atr · line 40
  • EMA (ema, ta.ema in v5)zxEMAData, Moving Average Length (10)ZLEMA · line 54
  • Linreg (linreg, ta.linreg in v5)Source (hl2), Moving Average Length (10), 0lrc · line 55
  • Linreg (linreg, ta.linreg in v5)Source (hl2), Moving Average Length (10), 1lrc1 · line 56
  • Linreg (linreg, ta.linreg in v5)Source (hl2), Moving Average Length (10), 0TSF · line 58
  • SMA / EMA / WMA (sma, ta.sma in v5)Source (hl2), Moving Average Length (10)ma · line 62
  • ATR (atr, ta.atr in v5)20atrCurrency · line 108
  • Crossover (crossover, ta.crossover in v5)MAvg, PMaxbuySignalk · line 111
  • Crossunder (crossunder, ta.crossunder in v5)MAvg, PMaxsellSignallk · line 116
  • Crossover (crossover, ta.crossover in v5)Source (hl2), PMaxbuySignalc · line 122
  • Crossunder (crossunder, ta.crossunder in 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

OrderFires whenBy defaultLine
Open buySignalk long(buySignalk and showsignalsk and inDateRange)On114
order sellSignallk short(sellSignallk and showsignalsk and inDateRange)On119
Open BuyS short(buySignalc and showsignalsc and inDateRange)On125
order SellS long(sellSignallc and showsignalsc and inDateRange)On129
Close (not inDateRange)On137

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Alerts

AlertCallMessageLine
Cross AlertalertconditionPMax - Moving Avg Crossing!100
Crossover AlarmalertconditionMoving Avg BUY SIGNAL!101
Crossunder AlarmalertconditionMoving Avg SELL SIGNAL!102
Price Cross AlertalertconditionPMax - Price Crossing!103
Price Crossover AlarmalertconditionPRICE OVER PMax - BUY SIGNAL!104
Price Crossunder AlarmalertconditionPRICE UNDER PMax - SELL SIGNAL!105

Does it repaint?

No

No repainting patterns in the source.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—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.

ScriptSharesTypeNetTradesMax drawdown
Strategy - Profit Maximizer by PMax this page—v4 strategy0.0%00.0%
Profit Maximizer PMax Strategy - Long-Short by melihtunasma atr ema linregv4 strategy+16.2%427.8%
Open Close Cross Strategy plus Explorer by roses27sma ema wma linreg atrv4 strategydoes not run in Zeal Terminal
Profit Maximizer Strategy by SoftKill21sma atr ema linregv4 strategy−3.6%53.6%
Y-Profit Maximizer Strategy with Exit Points by Enes_Yetkin_ema sma atr linregv4 strategy−1.9%1330.4%
Strategy Myth-Busting #2 - Braid Filter+ADX+EMA-Trend - [MYN] by myncryptosma ema wma atrv5 strategy−47.2%448.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 35 msWith a workaround 1,000 bars in 119 msNot measured
PineTSNo 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()