Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Profit Maximizer PMax Strategy - Long-Short

A Pine Script v4 strategy built on SMA (tr, 10), ATR (10) and EMA (zxEMAData, 10). It has 6 order rules, 4 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 10000 in cash and pays no commission. 10 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 Profit Maximizer PMax Strategy - Long-Short repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
How did Profit Maximizer PMax Strategy - Long-Short do on BTCUSDT 1D with default settings?
+16.17%
From 26 Jan 2024 to 21 Oct 2026, over 4 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Profit Maximizer PMax Strategy - Long-Short be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
What alerts does Profit Maximizer PMax Strategy - Long-Short have?
6
Cross Alert; Crossover Alarm; Crossunder Alarm; Price Cross Alert; and more.
Does Profit Maximizer PMax Strategy - Long-Short 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
  • 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 (10)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$12,430$20,253Equity from $10,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.
Net profit
+16.17%
$1,617.25
Buy and hold
+102.5%
same period
Closed trades
4
2 won · 2 lost
Profitable
50.0%
of closed trades
Profit factor
1.65
gross profit ÷ gross loss
Max drawdown
27.83%
−$2,783.13

One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A long position was still open at the last bar. 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.

  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

  • Note

    Uses an argument v6 removed

    when = on line 101, 103, 106, 108, 111, 113. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 80

    transp = on line 80. v5 folds the transparency into the colour with color.new(c, transp).

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.
  • 6 strategy calls use the when = argument (line 101, 103, 106, 108, 111, 113). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

Same 4 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 6: //@version=4 → //@version=5
  • Line 9: input(type = input.integer) → input.int()
  • Line 10: input(type = input.float) → input.float()
  • Line 14: input(type = input.bool) → input.bool()
  • Line 15: input(type = input.bool) → input.bool()
  • Line 18: input(type = input.bool) → input.bool()
33 more edits
  • Line 19: input(type = input.bool) → input.bool()
  • Line 20: sma → ta.sma
  • Line 20: tr → ta.tr
  • Line 21: atr → ta.atr
  • Line 25: sum → math.sum
  • Line 26: sum → math.sum
  • Line 29: abs → math.abs
  • Line 29: abs → math.abs
  • Line 33: round → math.round
  • Line 35: ema → ta.ema
  • Line 36: linreg → ta.linreg
  • Line 37: linreg → ta.linreg
  • Line 39: linreg → ta.linreg
  • Line 43: sma → ta.sma
  • Line 46: ema → ta.ema
  • Line 49: wma → ta.wma
  • Line 52: sma → ta.sma
  • Line 52: sma → ta.sma
  • Line 52: ceil → math.ceil
  • Line 52: floor → math.floor
  • Line 71: max → math.max
  • Line 74: min → math.min
  • Line 80: transp = 0 → color.new(color.red, 0)
  • Line 81: cross → ta.cross
  • Line 82: crossover → ta.crossover
  • Line 83: crossunder → ta.crossunder
  • Line 84: cross → ta.cross
  • Line 85: crossover → ta.crossover
  • Line 86: crossunder → ta.crossunder
  • Line 87: crossover → ta.crossover
  • Line 89: crossunder → ta.crossunder
  • Line 91: crossover → ta.crossover
  • Line 93: crossunder → ta.crossunder
⋯//stretegy converter: @crypto_melih-//@version=4+//@version=5strategy("Profit Maximizer Strategy Long-Short", shorttitle="PMax-Strategy", overlay=true, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency=currency.USD, commission_value=0, commission_type=strategy.commission.percent)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="EMA", options=["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"])⋯condition = input(title="Signal Type", defval="Only Crossing Signals", options=["Only Crossing Signals", "Only Price/Pmax Crossing Signals"])-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)//showsignalsc = input(title="Show Price/Pmax Crossing Signals?", type=input.bool, defval=false)-highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)+highlighting = input.bool(title="Highlighter On/Off ?", defval=true)-long_short = input(defval = false, title = "Long-Short", type=input.bool)+long_short = input.bool(defval = false, title = "Long-Short")-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!")-buySignalk = crossover(MAvg, PMax)+buySignalk = ta.crossover(MAvg, PMax)//plotshape(buySignalk and showsignalsk ? PMax*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)-sellSignallk = crossunder(MAvg, PMax)+sellSignallk = ta.crossunder(MAvg, PMax)//plotshape(sellSignallk and showsignalsk ? PMax*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)-buySignalc = crossover(src, PMax)+buySignalc = ta.crossover(src, PMax)//plotshape(buySignalc and showsignalsc ? PMax*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=#0F18BF, textcolor=color.white, transp=0)-sellSignallc = crossunder(src, PMax)+sellSignallc = ta.crossunder(src, PMax)//plotshape(sellSignallc and showsignalsc ? PMax*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=#0F18BF, textcolor=color.white, transp=0)⋯

Clean v5

VerifiedDownload the v5 script

Same 4 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 8: input() → input.source()
  • Line 11: input() → input.string()
  • Line 12: input() → input.int()
  • Line 13: input() → input.string()
  • Line 101: when = buySignalk → if block
  • Line 103: when = buySignalc → if block
4 more edits
  • Line 106: when = sellSignallk → if block
  • Line 108: when = sellSignallc → if block
  • Line 111: when = sellSignallk → if block
  • Line 113: when = sellSignallc → if block
⋯strategy("Profit Maximizer Strategy Long-Short", shorttitle="PMax-Strategy", overlay=true, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency=currency.USD, commission_value=0, commission_type=strategy.commission.percent)-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="EMA", options=["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"])+mav = input.string(title="Moving Average Type", defval="EMA", 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)-condition = input(title="Signal Type", defval="Only Crossing Signals", options=["Only Crossing Signals", "Only Price/Pmax Crossing Signals"])+condition = input.string(title="Signal Type", defval="Only Crossing Signals", options=["Only Crossing Signals", "Only Price/Pmax Crossing Signals"])changeATR= input.bool(title="Change ATR Calculation Method ?", defval=true)⋯if(condition=="Only Crossing Signals")-    strategy.entry("BUY", strategy.long, when = buySignalk)+    if buySignalk+        strategy.entry("BUY", strategy.long)else-    strategy.entry("BUY", strategy.long, when = buySignalc)+    if buySignalc+        strategy.entry("BUY", strategy.long)if(long_short)    if(condition=="Only Crossing Signals")-        strategy.entry("SELL", strategy.short, when = sellSignallk)+        if sellSignallk+            strategy.entry("SELL", strategy.short)    else-        strategy.entry("SELL", strategy.short, when = sellSignallc)+        if sellSignallc+            strategy.entry("SELL", strategy.short)else    if(condition=="Only Crossing Signals")-        strategy.close("BUY", when = sellSignallk)+        if sellSignallk+            strategy.close("BUY")    else-        strategy.close("BUY", when = sellSignallc)+        if sellSignallc+            strategy.close("BUY")

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L95: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.

⋯//stretegy converter: @crypto_melih-//@version=5+//@version=6strategy("Profit Maximizer Strategy Long-Short", shorttitle="PMax-Strategy", overlay=true, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency=currency.USD, commission_value=0, commission_type=strategy.commission.percent)⋯

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 TypeEMAstring · options ["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"]line 42 line 45 line 48 line 51 line 54 line 57 line 60 line 63
Moving Average Length10int · min 1valpha wwalpha zxLag ZLEMA lrc lrc1 TSF ma MAvg
Signal TypeOnly Crossing Signalsstring · options ["Only Crossing Signals", "Only Price/Pmax Crossing Signals"]entry BUY entry BUY entry SELL entry SELL close BUY close BUY line 100 line 105 line 110
Change ATR Calculation Method ?trueboolatr
Show Moving Average?trueboolMoving Avg Line
Highlighter On/Off ?trueboollongFillColor shortFillColor
Long-Shortfalseboolline 104

What it calculates

  • SMA (sma, ta.sma in v5)tr, ATR Length (10)atr2 · line 20
  • ATR (atr, ta.atr in v5)ATR Length (10)atr · line 21
  • EMA (ema, ta.ema in v5)zxEMAData, Moving Average Length (10)ZLEMA · line 35
  • Linreg (linreg, ta.linreg in v5)Source (hl2), Moving Average Length (10), 0lrc · line 36
  • Linreg (linreg, ta.linreg in v5)Source (hl2), Moving Average Length (10), 1lrc1 · line 37
  • Linreg (linreg, ta.linreg in v5)Source (hl2), Moving Average Length (10), 0TSF · line 39
  • SMA / EMA / WMA (sma, ta.sma in v5)Source (hl2), Moving Average Length (10)ma · line 43
  • Crossover (crossover, ta.crossover in v5)MAvg, PMaxbuySignalk · line 87
  • Crossunder (crossunder, ta.crossunder in v5)MAvg, PMaxsellSignallk · line 89
  • Crossover (crossover, ta.crossover in v5)Source (hl2), PMaxbuySignalc · line 91
  • Crossunder (crossunder, ta.crossunder in v5)Source (hl2), PMaxsellSignallc · line 93

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.

PeriodsATR Lengthsetting · 10high · low · closehigh · low · closeprice datalengthMoving Average Lengthsetting · 10hl2hl2price dataMultiplierATR Multipliersetting · 3.0ohlc4ohlc4price dataatr2SMA→ atr2atrATR→ atrZLEMAEMA→ ZLEMAlrcLinreg→ lrclrc1Linreg→ lrc1TSFLinreg→ TSFmaSMA / EMA / WMA→ mabuySignalkCrossover→ buySignalksellSignallkCrossunder→ sellSignallkbuySignalcCrossover→ buySignalcsellSignallcCrossunder→ sellSignallcvalpha, wwalpha, zxLagvalpha · wwalpha +13 valuesvud1, vdd1vud1 · vdd12 valuesvUDvUDvaluevDDvDDvaluevCMOvCMOvalueVARVARvalueWWMAWWMAvaluezxEMADatazxEMADatavaluelrslrsvalueMAvgMAvgvaluelongStoplongStopvaluelongStopPrevlongStopPrevvalueshortStopshortStopvalueshortStopPrevshortStopPrevvaluedirdirvaluePMaxPMaxvaluelongFillColor, shortFillColorColourlongFillColor · shortFillColorentry:BUYOpen BUYstrategy.entryentry:SELLOpen SELLstrategy.entryclose:BUYClose BUYstrategy.closeplot:79Moving Avg Lineplotplot:80PMaxplotalertcondition:81Cross Alertalertconditionalertcondition:82Crossover Alarmalertconditionalertcondition:83Crossunder Alarmalertconditionalertcondition:84Price Cross Alertalertconditionalertcondition:85Price Crossover Alarmalertconditionalertcondition:86Price Crossunder Alarmalertconditionplot:95plotfill:UpTrend HighligterUpTrend Highligterfillfill:DownTrend HighligterDownTrend Highligterfill

Order rules

OrderFires whenBy defaultLine
Open BUY longbuySignalkOn101
Open BUY longbuySignalcOn103
Open SELL shortsellSignallkOn106
Open SELL shortsellSignallcOn108
Close BUYsellSignallkOn111
Close BUYsellSignallcOn113

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!81
Crossover AlarmalertconditionMoving Avg BUY SIGNAL!82
Crossunder AlarmalertconditionMoving Avg SELL SIGNAL!83
Price Cross AlertalertconditionPMax - Price Crossing!84
Price Crossover AlarmalertconditionPRICE OVER PMax - BUY SIGNAL!85
Price Crossunder AlarmalertconditionPRICE UNDER PMax - SELL SIGNAL!86

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

1/1trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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 1D+16.2%+102.5%450%1.6527.8%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+14.1%+5.5%560%2.569.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+48.6%+9.8%540%2.2332.7%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+25.6%+8.4%450%3.5710.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−75.0%+16.7%540%0.1698.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+19.5%+21.5%540%2.6410.9%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+21.6%+148.3%333%2.2016.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+4.2%+17.1%425%1.2118.6%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market0—$0.00
Sideways market450%$1,617.25
Falling market0—$0.00

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

21.0%

The 95th percentile of the worst drawdown when the same 4 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 12.5% to 21.0%; the tick is what actually happened, 12.5%. Order luck alone moves it this much.

0%24%
All 4 trades
SideEntryExitBarsP&L
long28 Jul 2024 67,896.5020 Aug 2024 59,438.5023−$1,245.72
long30 Sep 2024 65,602.001 Mar 2025 84,349.90152$2,857.83
long2 May 2025 96,489.9020 Oct 2025 108,643.00171$1,259.50
long22 Apr 2026 76,336.103 Jun 2026 66,760.8042−$1,254.36

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
Profit Maximizer PMax Strategy - Long-Short this page—v4 strategy+16.2%427.8%
Strategy - Profit Maximizer by PMax by MartinCresposma atr ema linregv4 strategyNo trades on this market
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 34 msYes 1,000 bars in 66 msNot measured
PineTSNo v5 and v6 only—Not measured

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

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © melihtuna//developer: @KivancOzbilgic//author: @KivancOzbilgic//stretegy converter: @crypto_melih//@version=4strategy("Profit Maximizer Strategy Long-Short", shorttitle="PMax-Strategy", overlay=true, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency=currency.USD, commission_value=0, commission_type=strategy.commission.percent)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="EMA", options=["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"])length =input(10, "Moving Average Length", minval=1)condition = input(title="Signal Type", defval="Only Crossing Signals", options=["Only Crossing Signals", "Only Price/Pmax Crossing Signals"])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)long_short = input(defval = false, title = "Long-Short", type=input.bool)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!")buySignalk = crossover(MAvg, PMax)//plotshape(buySignalk and showsignalsk ? PMax*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)sellSignallk = crossunder(MAvg, PMax)//plotshape(sellSignallk and showsignalsk ? PMax*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)buySignalc = crossover(src, PMax)//plotshape(buySignalc and showsignalsc ? PMax*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=#0F18BF, textcolor=color.white, transp=0)sellSignallc = crossunder(src, PMax)//plotshape(sellSignallc and showsignalsc ? PMax*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=#0F18BF, textcolor=color.white, transp=0)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)if(condition=="Only Crossing Signals")    strategy.entry("BUY", strategy.long, when = buySignalk)else    strategy.entry("BUY", strategy.long, when = buySignalc)if(long_short)    if(condition=="Only Crossing Signals")        strategy.entry("SELL", strategy.short, when = sellSignallk)    else        strategy.entry("SELL", strategy.short, when = sellSignallc)else    if(condition=="Only Crossing Signals")        strategy.close("BUY", when = sellSignallk)    else        strategy.close("BUY", when = sellSignallc)