Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

PMax Explorer STRATEGY & SCREENER

A Pine Script v4 strategy built on SMA (tr, 10), ATR (10) and Linreg (hl2, 10). It has 2 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 no commission. 41 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 PMax Explorer STRATEGY & SCREENER repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 2 of 2 trades.
How did PMax Explorer STRATEGY & SCREENER do on BTCUSDT 1D with default settings?
+9.20%
From 26 Jan 2024 to 21 Oct 2026, over 9 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can PMax Explorer STRATEGY & SCREENER 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 PMax Explorer STRATEGY & SCREENER have?
6
Cross Alert; Crossover Alarm; Crossunder Alarm; Price Cross Alert; and more.
Does PMax Explorer STRATEGY & SCREENER 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
Confirmed Reversal: 40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$115,564$202,527Equity from $100,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. Lines, boxes and labels are the script's own drawings, the most recent ones its limits keep. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market. Data the page supplies at the chart's own timeframe (another symbol, or Heikin-Ashi) reaches the script one bar later in Zeal Terminal's engine than on TradingView. The live re-run is not offered here: the script requests EURUSD D, XAUUSD D, AMZN D, TSLA D, ETHBTC D, XBTUSD D, XRPBTC D, THYAO D, GARAN D, USDTRY D, PETKM D, AAPL D, TUPRS D, HALKB D, AVAXUSDT D, ETHUSDT D, UKOIL D, ABNB D, SISE D, which this page cannot load in your browser.

Needs EURUSD D data, not available: EURUSD is not on Binance Needs XAUUSD D data, not available: XAUUSD is not on Binance Needs AMZN D data, not available: not a Binance spot market Needs TSLA D data, not available: not a Binance spot market Needs XBTUSD D data, not available: XBTUSD is not on Binance Needs THYAO D data, not available: THYAO is not on Binance Needs GARAN D data, not available: GARAN is not on Binance Needs USDTRY D data, not available: USDTRY is not on Binance Needs PETKM D data, not available: PETKM is not on Binance Needs AAPL D data, not available: not a Binance spot market Needs TUPRS D data, not available: TUPRS is not on Binance Needs HALKB D data, not available: HALKB is not on Binance Needs UKOIL D data, not available: UKOIL is not on Binance Needs ABNB D data, not available: not a Binance spot market Needs SISE D data, not available: not a Binance spot market Values that depend on it are empty on this chart.

Net profit
+9.20%
$9,203.02
Buy and hold
+102.5%
same period
Closed trades
9
3 won · 6 lost
Profitable
33.3%
of closed trades
Profit factor
1.17
gross profit ÷ gross loss
Max drawdown
27.37%
−$27,368.00

One run with the author's default settings, $100,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

    1 setting does nothing

    “=Backtest Inputs=” is declared but never read.

  • 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 136, 138. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 87

    transp = on line 87, 95, 97, 99, 101. 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, security → request.security.
  • 2 strategy calls use the when = argument (line 136, 138). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 5: //@version=4 → //@version=5
  • Line 8: input(type = input.integer) → input.int()
  • Line 9: input(type = input.float) → input.float()
  • Line 12: input(type = input.bool) → input.bool()
  • Line 13: input(type = input.bool) → input.bool()
  • Line 14: input(type = input.bool) → input.bool()
80 more edits
  • Line 15: input(type = input.bool) → input.bool()
  • Line 16: input(type = input.bool) → input.bool()
  • Line 17: sma → ta.sma
  • Line 17: tr → ta.tr
  • Line 18: atr → ta.atr
  • Line 23: sum → math.sum
  • Line 24: sum → math.sum
  • Line 27: abs → math.abs
  • Line 27: abs → math.abs
  • Line 35: round → math.round
  • Line 37: ema → ta.ema
  • Line 40: linreg → ta.linreg
  • Line 41: linreg → ta.linreg
  • Line 43: linreg → ta.linreg
  • Line 48: sma → ta.sma
  • Line 51: ema → ta.ema
  • Line 54: wma → ta.wma
  • Line 57: sma → ta.sma
  • Line 57: sma → ta.sma
  • Line 57: ceil → math.ceil
  • Line 57: floor → math.floor
  • Line 77: max → math.max
  • Line 80: min → math.min
  • Line 87: transp = 0 → color.new(color.red, 0)
  • Line 88: cross → ta.cross
  • Line 89: crossover → ta.crossover
  • Line 90: crossunder → ta.crossunder
  • Line 91: cross → ta.cross
  • Line 92: crossover → ta.crossover
  • Line 93: crossunder → ta.crossunder
  • Line 94: crossover → ta.crossover
  • Line 95: transp = 0 → color.new(color.green, 0)
  • Line 96: crossunder → ta.crossunder
  • Line 97: transp = 0 → color.new(color.red, 0)
  • Line 98: crossover → ta.crossover
  • Line 99: transp = 0 → color.new(#0F18BF, 0)
  • Line 100: crossunder → ta.crossunder
  • Line 101: transp = 0 → color.new(#0F18BF, 0)
  • Line 139: input(type = input.symbol) → input.symbol()
  • Line 140: input(type = input.symbol) → input.symbol()
  • Line 141: input(type = input.symbol) → input.symbol()
  • Line 142: input(type = input.symbol) → input.symbol()
  • Line 143: input(type = input.symbol) → input.symbol()
  • Line 144: input(type = input.symbol) → input.symbol()
  • Line 145: input(type = input.symbol) → input.symbol()
  • Line 146: input(type = input.symbol) → input.symbol()
  • Line 147: input(type = input.symbol) → input.symbol()
  • Line 148: input(type = input.symbol) → input.symbol()
  • Line 149: input(type = input.symbol) → input.symbol()
  • Line 150: input(type = input.symbol) → input.symbol()
  • Line 151: input(type = input.symbol) → input.symbol()
  • Line 152: input(type = input.symbol) → input.symbol()
  • Line 153: input(type = input.symbol) → input.symbol()
  • Line 154: input(type = input.symbol) → input.symbol()
  • Line 155: input(type = input.symbol) → input.symbol()
  • Line 156: input(type = input.symbol) → input.symbol()
  • Line 157: input(type = input.symbol) → input.symbol()
  • Line 158: input(type = input.symbol) → input.symbol()
  • Line 164: max → math.max
  • Line 166: min → math.min
  • Line 177: security → request.security
  • Line 178: security → request.security
  • Line 179: security → request.security
  • Line 180: security → request.security
  • Line 181: security → request.security
  • Line 182: security → request.security
  • Line 183: security → request.security
  • Line 184: security → request.security
  • Line 185: security → request.security
  • Line 186: security → request.security
  • Line 187: security → request.security
  • Line 188: security → request.security
  • Line 189: security → request.security
  • Line 190: security → request.security
  • Line 191: security → request.security
  • Line 192: security → request.security
  • Line 193: security → request.security
  • Line 194: security → request.security
  • Line 195: security → request.security
  • Line 196: security → request.security
⋯//author: KivancOzbilgic-//@version=4+//@version=5strategy("PMax Explorer", shorttitle="PMEx", overlay=true)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"])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)-atr2 = sma(tr, Periods)+atr2 = ta.sma(ta.tr, Periods)-atr= changeATR ? atr(Periods) : atr2+atr= changeATR ? ta.atr(Periods) : atr2Var_Func(src,length)=>⋯    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])VAR=Var_Func(src,length)⋯Zlema_Func(src,length)=>-    zxLag = length/2==round(length/2) ? length/2 : (length - 1) / 2+    zxLag = length/2==math.round(length/2) ? length/2 : (length - 1) / 2    zxEMAData = (src + (src - src[zxLag]))-    ZLEMA = ema(zxEMAData, length)+    ZLEMA = ta.ema(zxEMAData, length)ZLEMA=Zlema_Func(src,length)Tsf_Func(src,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)+lrsTSF=Tsf_Func(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) : longStop    shortStop = MAvg + Multiplier*atr    shortStopPrev = nz(shortStop[1], shortStop)-    shortStop := MAvg < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop+    shortStop := MAvg < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop    dir = 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)+plotshape(buySignalk and showsignalsk ? PMax*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.white)-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)+plotshape(sellSignallk and showsignalsk ? PMax*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.white)-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)+plotshape(buySignalc and showsignalsc ? PMax*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(#0F18BF, 0), textcolor=color.white)-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)+plotshape(sellSignallc and showsignalsc ? PMax*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(#0F18BF, 0), textcolor=color.white)mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0,display=display.none)⋯    strategy.entry("Short", strategy.short,when=Timerange())-t1=input('EURUSD',   title='Symbol 01',type=input.symbol)+t1=input.symbol('EURUSD',   title='Symbol 01')-t2=input('XAUUSD',    title='Symbol 02',type=input.symbol)+t2=input.symbol('XAUUSD',    title='Symbol 02')-t3=input('AMZN',    title='Symbol 03',type=input.symbol)+t3=input.symbol('AMZN',    title='Symbol 03')-t4=input('TSLA',    title='Symbol 04',type=input.symbol)+t4=input.symbol('TSLA',    title='Symbol 04')-t5=input('BTCUSDT',    title='Symbol 05',type=input.symbol)+t5=input.symbol('BTCUSDT',    title='Symbol 05')-t6=input('ETHBTC',    title='Symbol 06',type=input.symbol)+t6=input.symbol('ETHBTC',    title='Symbol 06')-t7=input('XBTUSD',    title='Symbol 07',type=input.symbol)+t7=input.symbol('XBTUSD',    title='Symbol 07')-t8=input('XRPBTC',    title='Symbol 08',type=input.symbol)+t8=input.symbol('XRPBTC',    title='Symbol 08')-t9=input('THYAO',   title='Symbol 09',type=input.symbol)+t9=input.symbol('THYAO',   title='Symbol 09')-t10=input('GARAN',    title='Symbol 10',type=input.symbol)+t10=input.symbol('GARAN',    title='Symbol 10')-t11=input('USDTRY',      title='Symbol 11',type=input.symbol)+t11=input.symbol('USDTRY',      title='Symbol 11')-t12=input('PETKM',      title='Symbol 12',type=input.symbol)+t12=input.symbol('PETKM',      title='Symbol 12')-t13=input('AAPL',      title='Symbol 13',type=input.symbol)+t13=input.symbol('AAPL',      title='Symbol 13')-t14=input('TUPRS',      title='Symbol 14',type=input.symbol)+t14=input.symbol('TUPRS',      title='Symbol 14')-t15=input('HALKB',      title='Symbol 15',type=input.symbol)+t15=input.symbol('HALKB',      title='Symbol 15')-t16=input('AVAXUSDT',     title='Symbol 16',type=input.symbol)+t16=input.symbol('AVAXUSDT',     title='Symbol 16')-t17=input('ETHUSDT',    title='Symbol 17',type=input.symbol)+t17=input.symbol('ETHUSDT',    title='Symbol 17')-t18=input('UKOIL',    title='Symbol 18',type=input.symbol)+t18=input.symbol('UKOIL',    title='Symbol 18')-t19=input('ABNB',    title='Symbol 19',type=input.symbol)+t19=input.symbol('ABNB',    title='Symbol 19')-t20=input('SISE',    title='Symbol 20',type=input.symbol)+t20=input.symbol('SISE',    title='Symbol 20')Pmax(Multiplier, Periods) =>⋯    TrendUp = 0.0-    TrendUp := MAvg[1]>TrendUp[1] ? max(Up,TrendUp[1]) : Up+    TrendUp := MAvg[1]>TrendUp[1] ? math.max(Up,TrendUp[1]) : Up    TrendDown = 0.0-    TrendDown := MAvg[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn+    TrendDown := MAvg[1]<TrendDown[1]? math.min(Dn,TrendDown[1]) : Dn    Trend = 0.0⋯TrendReversal = Trend != Trend[1]-[t01, s01] = security(t1, timeframe.period, Pmax(Multiplier, Periods))+[t01, s01] = request.security(t1, timeframe.period, Pmax(Multiplier, Periods))-[t02, s02] = security(t2, timeframe.period, Pmax(Multiplier, Periods))+[t02, s02] = request.security(t2, timeframe.period, Pmax(Multiplier, Periods))-[t03, s03] = security(t3, timeframe.period, Pmax(Multiplier, Periods))+[t03, s03] = request.security(t3, timeframe.period, Pmax(Multiplier, Periods))-[t04, s04] = security(t4, timeframe.period, Pmax(Multiplier, Periods))+[t04, s04] = request.security(t4, timeframe.period, Pmax(Multiplier, Periods))-[t05, s05] = security(t5, timeframe.period, Pmax(Multiplier, Periods))+[t05, s05] = request.security(t5, timeframe.period, Pmax(Multiplier, Periods))-[t06, s06] = security(t6, timeframe.period, Pmax(Multiplier, Periods))+[t06, s06] = request.security(t6, timeframe.period, Pmax(Multiplier, Periods))-[t07, s07] = security(t7, timeframe.period, Pmax(Multiplier, Periods))+[t07, s07] = request.security(t7, timeframe.period, Pmax(Multiplier, Periods))-[t08, s08] = security(t8, timeframe.period, Pmax(Multiplier, Periods))+[t08, s08] = request.security(t8, timeframe.period, Pmax(Multiplier, Periods))-[t09, s09] = security(t9, timeframe.period, Pmax(Multiplier, Periods))+[t09, s09] = request.security(t9, timeframe.period, Pmax(Multiplier, Periods))-[t010, s010] = security(t10, timeframe.period, Pmax(Multiplier, Periods))+[t010, s010] = request.security(t10, timeframe.period, Pmax(Multiplier, Periods))-[t011, s011] = security(t11, timeframe.period, Pmax(Multiplier, Periods))+[t011, s011] = request.security(t11, timeframe.period, Pmax(Multiplier, Periods))-[t012, s012] = security(t12, timeframe.period, Pmax(Multiplier, Periods))+[t012, s012] = request.security(t12, timeframe.period, Pmax(Multiplier, Periods))-[t013, s013] = security(t13, timeframe.period, Pmax(Multiplier, Periods))+[t013, s013] = request.security(t13, timeframe.period, Pmax(Multiplier, Periods))-[t014, s014] = security(t14, timeframe.period, Pmax(Multiplier, Periods))+[t014, s014] = request.security(t14, timeframe.period, Pmax(Multiplier, Periods))-[t015, s015] = security(t15, timeframe.period, Pmax(Multiplier, Periods))+[t015, s015] = request.security(t15, timeframe.period, Pmax(Multiplier, Periods))-[t016, s016] = security(t16, timeframe.period, Pmax(Multiplier, Periods))+[t016, s016] = request.security(t16, timeframe.period, Pmax(Multiplier, Periods))-[t017, s017] = security(t17, timeframe.period, Pmax(Multiplier, Periods))+[t017, s017] = request.security(t17, timeframe.period, Pmax(Multiplier, Periods))-[t018, s018] = security(t18, timeframe.period, Pmax(Multiplier, Periods))+[t018, s018] = request.security(t18, timeframe.period, Pmax(Multiplier, Periods))-[t019, s019] = security(t19, timeframe.period, Pmax(Multiplier, Periods))+[t019, s019] = request.security(t19, timeframe.period, Pmax(Multiplier, Periods))-[t020, s020] = security(t20, timeframe.period, Pmax(Multiplier, Periods))+[t020, s020] = request.security(t20, timeframe.period, Pmax(Multiplier, Periods))tr01 = t01 != t01[1], up01 = t01 == 1, dn01 = t01 == -1⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 7: input() → input.source()
  • Line 10: input() → input.string()
  • Line 11: input() → input.int()
  • Line 107: input() → input.bool()
  • Line 108: input() → input.int()
  • Line 109: input() → input.int()
10 more edits
  • Line 110: input() → input.string()
  • Line 124: input() → input.bool()
  • Line 125: input() → input.int()
  • Line 126: input() → input.int()
  • Line 127: input() → input.int()
  • Line 128: input() → input.int()
  • Line 129: input() → input.int()
  • Line 130: input() → input.int()
  • Line 136: when = Timerange() → if block
  • Line 138: when = Timerange() → if block
⋯strategy("PMax Explorer", shorttitle="PMEx", overlay=true)-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)changeATR= input.bool(title="Change ATR Calculation Method ?", defval=true)⋯fill(mPlot, pALL, title="DownTrend Highligter", color=shortFillColor)-showscr = input(true, title="Show Screener Label")+showscr = input.bool(true, title="Show Screener Label")-posX_scr = input(20, title="Pos. Label x-axis")+posX_scr = input.int(20, title="Pos. Label x-axis")-posY_scr = input(1, title="Pos. Size Label y-axis")+posY_scr = input.int(1, title="Pos. Size Label y-axis")-colinput = input(title="Label Color", defval="Blue", options=["White", "Black", "Red", "Green", "Yellow", "Blue"])+colinput = input.string(title="Label Color", defval="Blue", options=["White", "Black", "Red", "Green", "Yellow", "Blue"])col = color.gray⋯    col:=color.blue-dummy0 = input(true, title = "=Backtest Inputs=")+dummy0 = input.bool(true, title = "=Backtest Inputs=")-FromDay    = input(defval = 1, title = "From Day", minval = 1, maxval = 31)+FromDay    = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)-FromMonth  = input(defval = 1, title = "From Month", minval = 1, maxval = 12)+FromMonth  = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)-FromYear   = input(defval = 2005, title = "From Year", minval = 2005)+FromYear   = input.int(defval = 2005, title = "From Year", minval = 2005)-ToDay      = input(defval = 1, title = "To Day", minval = 1, maxval = 31)+ToDay      = input.int(defval = 1, title = "To Day", minval = 1, maxval = 31)-ToMonth    = input(defval = 1, title = "To Month", minval = 1, maxval = 12)+ToMonth    = input.int(defval = 1, title = "To Month", minval = 1, maxval = 12)-ToYear     = input(defval = 9999, title = "To Year", minval = 2006)+ToYear     = input.int(defval = 9999, title = "To Year", minval = 2006)Start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)⋯if buySignalk-    strategy.entry("Long", strategy.long,when=Timerange())+    if Timerange()+        strategy.entry("Long", strategy.long)if sellSignallk-    strategy.entry("Short", strategy.short,when=Timerange())+    if Timerange()+        strategy.entry("Short", strategy.short)t1=input.symbol('EURUSD',   title='Symbol 01')⋯

Does it run in Pine Script v6?

No

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

⋯//author: KivancOzbilgic-//@version=5+//@version=6strategy("PMax Explorer", shorttitle="PMEx", overlay=true)⋯

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 ZLEMA lrc lrc1 TSF ma MAvg PMax buySignalc sellSignallc Price Cross Alert Price Crossover Alarm Price Crossunder Alarm
ATR Length10int (written input.integer)atr2 atr Trend Tsl t01 s01 t02 s02 t03 s03 t04 s04 t05 s05 t06 s06 t07 s07 t08 s08 t09 s09 t010 s010 t011 s011 t012 s012 t013 s013 t014 s014 t015 s015 t016 s016 t017 s017 t018 s018 t019 s019 t020 s020
ATR Multiplier3.0float · step 0.1longStop shortStop Up Dn Trend Tsl t01 s01 t02 s02 t03 s03 t04 s04 t05 s05 t06 s06 t07 s07 t08 s08 t09 s09 t010 s010 t011 s011 t012 s012 t013 s013 t014 s014 t015 s015 t016 s016 t017 s017 t018 s018 t019 s019 t020 s020
Moving Average TypeEMAstring · options ["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"]line 47 line 50 line 53 line 56 line 59 line 62 line 65 line 68
Moving Average Length10int · min 1valpha VAR wwalpha WWMA zxLag ZLEMA lrc lrc1 TSF ma MAvg PMax
Change ATR Calculation Method ?trueboolatr
Show Moving Average?trueboolMoving Avg Line
Show Crossing Signals?trueboolBuy Sell
Show Price/Pmax Crossing Signals?falseboolBuy Sell
Highlighter On/Off ?trueboollongFillColor shortFillColor
Show Screener Labeltruebool_lblscr
Pos. Label x-axis20int_lblscr
Pos. Size Label y-axis1int_lblscr
Label ColorBluestring · options ["White", "Black", "Red", "Green", "Yellow", "Blue"]line 112 line 114 line 116 line 118 line 120 line 122
=Backtest Inputs=trueboolunused
From Day1int · min 1 · max 31Start
From Month1int · min 1 · max 12Start
From Year2005int · min 2005Start
To Day1int · min 1 · max 31Finish
To Month1int · min 1 · max 12Finish
To Year9999int · min 2006Finish
Symbol 01EURUSDsymbolt01 s01 pot_label scr_label up_label dn_label
Symbol 02XAUUSDsymbolt02 s02 pot_label scr_label up_label dn_label
Symbol 03AMZNsymbolt03 s03 pot_label scr_label up_label dn_label
Symbol 04TSLAsymbolt04 s04 pot_label scr_label up_label dn_label
Symbol 05BTCUSDTsymbolt05 s05 pot_label scr_label up_label dn_label
Symbol 06ETHBTCsymbolt06 s06 pot_label scr_label up_label dn_label
Symbol 07XBTUSDsymbolt07 s07 pot_label scr_label up_label dn_label
Symbol 08XRPBTCsymbolt08 s08 pot_label scr_label up_label dn_label
Symbol 09THYAOsymbolt09 s09 pot_label scr_label up_label dn_label
Symbol 10GARANsymbolt010 s010 pot_label scr_label up_label dn_label
Symbol 11USDTRYsymbolt011 s011 pot_label scr_label up_label dn_label
Symbol 12PETKMsymbolt012 s012 pot_label scr_label up_label dn_label
Symbol 13AAPLsymbolt013 s013 pot_label scr_label up_label dn_label
Symbol 14TUPRSsymbolt014 s014 pot_label scr_label up_label dn_label
Symbol 15HALKBsymbolt015 s015 pot_label scr_label up_label dn_label
Symbol 16AVAXUSDTsymbolt016 s016 pot_label scr_label up_label dn_label
Symbol 17ETHUSDTsymbolt017 s017 pot_label scr_label up_label dn_label
Symbol 18UKOILsymbolt018 s018 pot_label scr_label up_label dn_label
Symbol 19ABNBsymbolt019 s019 pot_label scr_label up_label dn_label
Symbol 20SISEsymbolt020 s020 pot_label scr_label up_label dn_label

What it calculates

  • SMA (sma, ta.sma in v5)tr, ATR Length (10)atr2 · line 17
  • ATR (atr, ta.atr in v5)ATR Length (10)atr · line 18
  • Linreg (linreg, ta.linreg in v5)Source (hl2), Moving Average Length (10), 0lrc · line 40
  • Linreg (linreg, ta.linreg in v5)Source (hl2), Moving Average Length (10), 1lrc1 · line 41
  • SMA / EMA / WMA (sma, ta.sma in v5)Source (hl2), Moving Average Length (10)ma · line 48
  • Crossover (crossover, ta.crossover in v5)MAvg, PMaxbuySignalk · line 94
  • Crossunder (crossunder, ta.crossunder in v5)MAvg, PMaxsellSignallk · line 96
  • Crossover (crossover, ta.crossover in v5)Source (hl2), PMaxbuySignalc · line 98
  • Crossunder (crossunder, ta.crossunder in v5)Source (hl2), PMaxsellSignallc · line 100

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 128 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open Long longTimerange()On136
Open Short shortTimerange()On138

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!88
Crossover AlarmalertconditionMoving Avg BUY SIGNAL!89
Crossunder AlarmalertconditionMoving Avg SELL SIGNAL!90
Price Cross AlertalertconditionPMax - Price Crossing!91
Price Crossover AlarmalertconditionPRICE OVER PMax - BUY SIGNAL!92
Price Crossunder AlarmalertconditionPRICE UNDER PMax - SELL SIGNAL!93

Does it repaint?

No

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

2/2trades 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 data20 security call(s), none with lookahead on.
  • 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

Not run on other markets: the script requests EURUSD D, XAUUSD D, AMZN D, TSLA D, XBTUSD D, THYAO D, GARAN D, USDTRY D, PETKM D, AAPL D, TUPRS D, HALKB D, UKOIL D, ABNB D, SISE D, and that data is not available here (EURUSD is not on Binance; XAUUSD is not on Binance; not a Binance spot market; not a Binance spot market; XBTUSD is not on Binance; THYAO is not on Binance; GARAN is not on Binance; USDTRY is not on Binance; PETKM is not on Binance; not a Binance spot market; TUPRS is not on Binance; HALKB is not on Binance; UKOIL is not on Binance; not a Binance spot market; not a Binance spot market). Its results would rest on empty values.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market0—$0.00
Sideways market933%$9,203.02
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?

38.0%

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

0%44%
All 9 trades
SideEntryExitBarsP&L
short26 Jun 2024 61,806.0028 Jul 2024 67,896.5032−$6,090.48
long28 Jul 2024 67,896.5020 Aug 2024 59,438.5023−$8,457.99
short20 Aug 2024 59,438.5030 Sep 2024 65,602.0041−$6,163.51
long30 Sep 2024 65,602.001 Mar 2025 84,349.90152$18,747.90
short1 Mar 2025 84,349.902 May 2025 96,489.9062−$12,139.90
long2 May 2025 96,489.9020 Oct 2025 108,643.00171$12,152.90
short20 Oct 2025 108,643.0022 Apr 2026 76,336.10184$32,306.60
long22 Apr 2026 76,336.103 Jun 2026 66,760.8042−$9,575.30
short3 Jun 2026 66,760.8022 Aug 2026 78,338.0080−$11,577.20

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
PMax Explorer STRATEGY & SCREENER this page—v4 strategy+9.2%927.4%
Profit Maximizer PMax Strategy - Long-Short by melihtunasma atr ema linregv4 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%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 65 msWith a workaround 1,000 bars in 339 msNot measured
PineTSNo v5 and v6 only—Not measured

The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market. Data the page supplies at the chart's own timeframe (another symbol, or Heikin-Ashi) reaches the script one bar later in Zeal Terminal's engine than on TradingView.

“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/// © KivancOzbilgic//developer: KivancOzbilgic//author: KivancOzbilgic//@version=4strategy("PMax Explorer", shorttitle="PMEx", overlay=true)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)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)atr2 = sma(tr, Periods)atr= changeATR ? atr(Periods) : atr2Var_Func(src,length)=>    valpha=2/(length+1)    vud1=src>src[1] ? src-src[1] : 0    vdd1=src<src[1] ? src[1]-src : 0    vUD=sum(vud1,9)    vDD=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=Var_Func(src,length)Wwma_Func(src,length)=>    wwalpha = 1/ length    WWMA = 0.0    WWMA := wwalpha*src + (1-wwalpha)*nz(WWMA[1])WWMA=Wwma_Func(src,length)Zlema_Func(src,length)=>    zxLag = length/2==round(length/2) ? length/2 : (length - 1) / 2    zxEMAData = (src + (src - src[zxLag]))    ZLEMA = ema(zxEMAData, length)ZLEMA=Zlema_Func(src,length)Tsf_Func(src,length)=>    lrc = linreg(src, length, 0)    lrc1 = linreg(src,length,1)    lrs = (lrc-lrc1)    TSF = linreg(src, length, 0)+lrsTSF=Tsf_Func(src,length)getMA(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)Pmax_Func(src,length)=>    longStop = MAvg - Multiplier*atr    longStopPrev = nz(longStop[1], longStop)    longStop := MAvg > longStopPrev ? max(longStop, longStopPrev) : longStop    shortStop = MAvg + Multiplier*atr    shortStopPrev = nz(shortStop[1], shortStop)    shortStop := MAvg < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop    dir = 1    dir := nz(dir[1], dir)    dir := dir == -1 and MAvg > shortStopPrev ? 1 : dir == 1 and MAvg < longStopPrev ? -1 : dir    PMax = dir==1 ? longStop: shortStopPMax=Pmax_Func(src,length)plot(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)showscr = input(true, title="Show Screener Label")posX_scr = input(20, title="Pos. Label x-axis")posY_scr = input(1, title="Pos. Size Label y-axis")colinput = input(title="Label Color", defval="Blue", options=["White", "Black", "Red", "Green", "Yellow", "Blue"])col = color.grayif colinput=="White"    col:=color.whiteif colinput=="Black"    col:=color.blackif colinput=="Red"    col:=color.redif colinput=="Green"    col:=color.greenif colinput=="Yellow"    col:=color.yellowif colinput=="Blue"    col:=color.bluedummy0 = input(true, title = "=Backtest Inputs=")FromDay    = input(defval = 1, title = "From Day", minval = 1, maxval = 31)FromMonth  = input(defval = 1, title = "From Month", minval = 1, maxval = 12)FromYear   = input(defval = 2005, title = "From Year", minval = 2005)ToDay      = input(defval = 1, title = "To Day", minval = 1, maxval = 31)ToMonth    = input(defval = 1, title = "To Month", minval = 1, maxval = 12)ToYear     = input(defval = 9999, title = "To Year", minval = 2006)Start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)Finish    = timestamp(ToYear, ToMonth, ToDay, 23, 59)Timerange() =>    time >= Start and time <= Finish ? true : falseif buySignalk    strategy.entry("Long", strategy.long,when=Timerange())if sellSignallk    strategy.entry("Short", strategy.short,when=Timerange())t1=input('EURUSD',   title='Symbol 01',type=input.symbol)t2=input('XAUUSD',    title='Symbol 02',type=input.symbol)t3=input('AMZN',    title='Symbol 03',type=input.symbol)t4=input('TSLA',    title='Symbol 04',type=input.symbol)t5=input('BTCUSDT',    title='Symbol 05',type=input.symbol)t6=input('ETHBTC',    title='Symbol 06',type=input.symbol)t7=input('XBTUSD',    title='Symbol 07',type=input.symbol)t8=input('XRPBTC',    title='Symbol 08',type=input.symbol)t9=input('THYAO',   title='Symbol 09',type=input.symbol)t10=input('GARAN',    title='Symbol 10',type=input.symbol)t11=input('USDTRY',      title='Symbol 11',type=input.symbol)t12=input('PETKM',      title='Symbol 12',type=input.symbol)t13=input('AAPL',      title='Symbol 13',type=input.symbol)t14=input('TUPRS',      title='Symbol 14',type=input.symbol)t15=input('HALKB',      title='Symbol 15',type=input.symbol)t16=input('AVAXUSDT',     title='Symbol 16',type=input.symbol)t17=input('ETHUSDT',    title='Symbol 17',type=input.symbol)t18=input('UKOIL',    title='Symbol 18',type=input.symbol)t19=input('ABNB',    title='Symbol 19',type=input.symbol)t20=input('SISE',    title='Symbol 20',type=input.symbol)Pmax(Multiplier, Periods) =>    Up=MAvg-(Multiplier*atr)    Dn=MAvg+(Multiplier*atr)        TrendUp = 0.0    TrendUp := MAvg[1]>TrendUp[1] ? max(Up,TrendUp[1]) : Up    TrendDown = 0.0    TrendDown := MAvg[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn    Trend = 0.0    Trend := MAvg > TrendDown[1] ? 1: MAvg< TrendUp[1]? -1: nz(Trend[1],1)    Tsl = Trend==1? TrendUp: TrendDown        S_Buy = Trend == 1 ? 1 : 0    S_Sell = Trend != 1 ? 1 : 0        [Trend, Tsl][Trend, Tsl] =  Pmax(Multiplier, Periods)TrendReversal = Trend != Trend[1][t01, s01] = security(t1, timeframe.period, Pmax(Multiplier, Periods))[t02, s02] = security(t2, timeframe.period, Pmax(Multiplier, Periods))[t03, s03] = security(t3, timeframe.period, Pmax(Multiplier, Periods))[t04, s04] = security(t4, timeframe.period, Pmax(Multiplier, Periods))[t05, s05] = security(t5, timeframe.period, Pmax(Multiplier, Periods))[t06, s06] = security(t6, timeframe.period, Pmax(Multiplier, Periods))[t07, s07] = security(t7, timeframe.period, Pmax(Multiplier, Periods))[t08, s08] = security(t8, timeframe.period, Pmax(Multiplier, Periods))[t09, s09] = security(t9, timeframe.period, Pmax(Multiplier, Periods))[t010, s010] = security(t10, timeframe.period, Pmax(Multiplier, Periods))[t011, s011] = security(t11, timeframe.period, Pmax(Multiplier, Periods))[t012, s012] = security(t12, timeframe.period, Pmax(Multiplier, Periods))[t013, s013] = security(t13, timeframe.period, Pmax(Multiplier, Periods))[t014, s014] = security(t14, timeframe.period, Pmax(Multiplier, Periods))[t015, s015] = security(t15, timeframe.period, Pmax(Multiplier, Periods))[t016, s016] = security(t16, timeframe.period, Pmax(Multiplier, Periods))[t017, s017] = security(t17, timeframe.period, Pmax(Multiplier, Periods))[t018, s018] = security(t18, timeframe.period, Pmax(Multiplier, Periods))[t019, s019] = security(t19, timeframe.period, Pmax(Multiplier, Periods))[t020, s020] = security(t20, timeframe.period, Pmax(Multiplier, Periods))tr01 = t01 != t01[1], up01 = t01 == 1, dn01 = t01 == -1tr02 = t02 != t02[1], up02 = t02 == 1, dn02 = t02 == -1tr03 = t03 != t03[1], up03 = t03 == 1, dn03 = t03 == -1tr04 = t04 != t04[1], up04 = t04 == 1, dn04 = t04 == -1tr05 = t05 != t05[1], up05 = t05 == 1, dn05 = t05 == -1tr06 = t06 != t06[1], up06 = t06 == 1, dn06 = t06 == -1tr07 = t07 != t07[1], up07 = t07 == 1, dn07 = t07 == -1tr08 = t08 != t08[1], up08 = t08 == 1, dn08 = t08 == -1tr09 = t09 != t09[1], up09 = t09 == 1, dn09 = t09 == -1tr010 = t010 != t010[1], up010 = t010 == 1, dn010 = t010 == -1tr011 = t011 != t011[1], up011 = t011 == 1, dn011 = t011 == -1tr012 = t012 != t012[1], up012 = t012 == 1, dn012 = t012 == -1tr013 = t013 != t013[1], up013 = t013 == 1, dn013 = t013 == -1tr014 = t014 != t014[1], up014 = t014 == 1, dn014 = t014 == -1tr015 = t015 != t015[1], up015 = t015 == 1, dn015 = t015 == -1tr016 = t016 != t016[1], up016 = t016 == 1, dn016 = t016 == -1tr017 = t017 != t017[1], up017 = t017 == 1, dn017 = t017 == -1tr018 = t018 != t018[1], up018 = t018 == 1, dn018 = t018 == -1tr019 = t019 != t019[1], up019 = t019 == 1, dn019 = t019 == -1tr020 = t020 != t020[1], up020 = t020 == 1, dn020 = t020 == -1pot_label = 'Potential Reversal: \n'pot_label := tr01    ? pot_label + t1 + '\n'  : pot_labelpot_label := tr02    ? pot_label + t2 + '\n'  : pot_labelpot_label := tr03    ? pot_label + t3 + '\n'  : pot_labelpot_label := tr04    ? pot_label + t4 + '\n'  : pot_labelpot_label := tr05    ? pot_label + t5 + '\n'  : pot_labelpot_label := tr06    ? pot_label + t6 + '\n'  : pot_labelpot_label := tr07    ? pot_label + t7 + '\n'  : pot_labelpot_label := tr08    ? pot_label + t8 + '\n'  : pot_labelpot_label := tr09    ? pot_label + t9 + '\n'  : pot_labelpot_label := tr010    ? pot_label + t10 + '\n'  : pot_labelpot_label := tr011    ? pot_label + t11 + '\n'  : pot_labelpot_label := tr012    ? pot_label + t12 + '\n'  : pot_labelpot_label := tr013    ? pot_label + t13 + '\n'  : pot_labelpot_label := tr014    ? pot_label + t14 + '\n'  : pot_labelpot_label := tr015    ? pot_label + t15 + '\n'  : pot_labelpot_label := tr016    ? pot_label + t16 + '\n'  : pot_labelpot_label := tr017    ? pot_label + t17 + '\n'  : pot_labelpot_label := tr018    ? pot_label + t18 + '\n'  : pot_labelpot_label := tr019    ? pot_label + t19 + '\n'  : pot_labelpot_label := tr020    ? pot_label + t20 + '\n'  : pot_labelscr_label = 'Confirmed Reversal: \n'scr_label := tr01[1] ? scr_label + t1 + '\n'  : scr_labelscr_label := tr02[1] ? scr_label + t2 + '\n'  : scr_labelscr_label := tr03[1] ? scr_label + t3 + '\n'  : scr_labelscr_label := tr04[1] ? scr_label + t4 + '\n'  : scr_labelscr_label := tr05[1] ? scr_label + t5 + '\n'  : scr_labelscr_label := tr06[1] ? scr_label + t6 + '\n'  : scr_labelscr_label := tr07[1] ? scr_label + t7 + '\n'  : scr_labelscr_label := tr08[1] ? scr_label + t8 + '\n'  : scr_labelscr_label := tr09[1] ? scr_label + t9 + '\n'  : scr_labelscr_label := tr010[1] ? scr_label + t10 + '\n'  : scr_labelscr_label := tr011[1] ? scr_label + t11 + '\n'  : scr_labelscr_label := tr012[1] ? scr_label + t12 + '\n'  : scr_labelscr_label := tr013[1] ? scr_label + t13 + '\n'  : scr_labelscr_label := tr014[1] ? scr_label + t14 + '\n'  : scr_labelscr_label := tr015[1] ? scr_label + t15 + '\n'  : scr_labelscr_label := tr016[1] ? scr_label + t16 + '\n'  : scr_labelscr_label := tr017[1] ? scr_label + t17 + '\n'  : scr_labelscr_label := tr018[1] ? scr_label + t18 + '\n'  : scr_labelscr_label := tr019[1] ? scr_label + t19 + '\n'  : scr_labelscr_label := tr020[1] ? scr_label + t20 + '\n'  : scr_labelup_label = 'Uptrend: \n'up_label := up01[1] ? up_label + t1 + '\n'  : up_labelup_label := up02[1] ? up_label + t2 + '\n'  : up_labelup_label := up03[1] ? up_label + t3 + '\n'  : up_labelup_label := up04[1] ? up_label + t4 + '\n'  : up_labelup_label := up05[1] ? up_label + t5 + '\n'  : up_labelup_label := up06[1] ? up_label + t6 + '\n'  : up_labelup_label := up07[1] ? up_label + t7 + '\n'  : up_labelup_label := up08[1] ? up_label + t8 + '\n'  : up_labelup_label := up09[1] ? up_label + t9 + '\n'  : up_labelup_label := up010[1] ? up_label + t10 + '\n'  : up_labelup_label := up011[1] ? up_label + t11 + '\n'  : up_labelup_label := up012[1] ? up_label + t12 + '\n'  : up_labelup_label := up013[1] ? up_label + t13 + '\n'  : up_labelup_label := up014[1] ? up_label + t14 + '\n'  : up_labelup_label := up015[1] ? up_label + t15 + '\n'  : up_labelup_label := up016[1] ? up_label + t16 + '\n'  : up_labelup_label := up017[1] ? up_label + t17 + '\n'  : up_labelup_label := up018[1] ? up_label + t18 + '\n'  : up_labelup_label := up019[1] ? up_label + t19 + '\n'  : up_labelup_label := up020[1] ? up_label + t20 + '\n'  : up_labeldn_label = 'Downtrend: \n'dn_label := dn01[1] ? dn_label + t1 + '\n'  : dn_labeldn_label := dn02[1] ? dn_label + t2 + '\n'  : dn_labeldn_label := dn03[1] ? dn_label + t3 + '\n'  : dn_labeldn_label := dn04[1] ? dn_label + t4 + '\n'  : dn_labeldn_label := dn05[1] ? dn_label + t5 + '\n'  : dn_labeldn_label := dn06[1] ? dn_label + t6 + '\n'  : dn_labeldn_label := dn07[1] ? dn_label + t7 + '\n'  : dn_labeldn_label := dn08[1] ? dn_label + t8 + '\n'  : dn_labeldn_label := dn09[1] ? dn_label + t9 + '\n'  : dn_labeldn_label := dn010[1] ? dn_label + t10 + '\n'  : dn_labeldn_label := dn011[1] ? dn_label + t11 + '\n'  : dn_labeldn_label := dn012[1] ? dn_label + t12 + '\n'  : dn_labeldn_label := dn013[1] ? dn_label + t13 + '\n'  : dn_labeldn_label := dn014[1] ? dn_label + t14 + '\n'  : dn_labeldn_label := dn015[1] ? dn_label + t15 + '\n'  : dn_labeldn_label := dn016[1] ? dn_label + t16 + '\n'  : dn_labeldn_label := dn017[1] ? dn_label + t17 + '\n'  : dn_labeldn_label := dn018[1] ? dn_label + t18 + '\n'  : dn_labeldn_label := dn019[1] ? dn_label + t19 + '\n'  : dn_labeldn_label := dn020[1] ? dn_label + t20 + '\n'  : dn_labelf_colorscr (_valscr ) =>      _valscr  ? #00000000 : na     f_printscr (_txtscr ) =>      var _lblscr  = label(na),      label.delete(_lblscr ),      _lblscr  := label.new(     time + (time-time[1])*posX_scr ,      ohlc4[posY_scr],      _txtscr ,     xloc.bar_time,      yloc.price,      f_colorscr (  showscr ),     textcolor =  showscr ? col : na,      size = size.normal,      style=label.style_label_center     )f_printscr ( scr_label + '\n' + pot_label +'\n' + up_label + '\n' + dn_label)