Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Y-Profit Maximizer Strategy with Exit Points

A Pine Script v4 strategy built on EMA (89), SMA (tr, 10) and ATR (10). It has 6 order rules, 1 entry among them, and trades long only with the default settings. Exits use a profit target and no stop loss. Each trade commits 10000 in cash and pays 0.1% commission. 35 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 Y-Profit Maximizer Strategy with Exit Points repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 4 of 4 trades.
How did Y-Profit Maximizer Strategy with Exit Points do on BTCUSDT 1D with default settings?
−1.92%
From 26 Jan 2024 to 21 Oct 2026, over 13 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Y-Profit Maximizer Strategy with Exit Points 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.
Does Y-Profit Maximizer Strategy with Exit Points use a stop loss?
No
Its exits set a profit target but no stop.
Does Y-Profit Maximizer Strategy with Exit Points run in Zeal Terminal?
Yes
It compiles in 179 ms and runs 1,000 bars in 218 ms, in the browser.

BTCUSDT · 1D · default settings

  • ExMov
  • Most
  • Buy
  • Sell
  • TP
  • 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 (35)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$12,067$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
−1.92%
−$191.70
Buy and hold
+102.5%
same period
Closed trades
13
5 won · 8 lost
Profitable
38.5%
of closed trades
Profit factor
0.97
gross profit ÷ gross loss
Max drawdown
30.35%
−$3,035.33

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.

  • Likely bug

    ema(BBMacd, 9) ignores the settings line 200

    Line 200 hard-codes 9 where line 46 uses “T3 Length”. Changing those settings moves one band but not this one.

    ema(BBMacd,9)ema(BBMacd, length1)
  • Check

    6 settings do nothing

    “-------------------- PMax Setttings -------------------”, “-------------------- T3 Setttings --------------------”, “---------------- Take Profit Setttings --------------”, “Dominant Cycle Length”, “------------------- MOST Setttings ------------------”, “Buy/Sell Shapes On/Off ?” are declared but never read.

  • Check

    No stop loss

    strategy.exit is used without a stop, loss or trailing stop.

  • Note

    No slippage

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

  • Note

    Uses iff(), which v5 removed line 155

    iff() on line 155, 155, 155, 158, 158. v5 writes it as the ternary c ? a : b.

  • Note

    Uses transp =, which v5 removed line 208

    transp = on line 208, 213, 215, 217, 219, 221, 242. 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 ema → ta.ema, sma → ta.sma, atr → ta.atr, sum → math.sum, abs → math.abs, round → math.round, linreg → ta.linreg, wma → ta.wma, ceil → math.ceil, floor → math.floor, max → math.max, min → math.min, crossover → ta.crossover, crossunder → ta.crossunder, avg → math.avg, highest → ta.highest, lowest → ta.lowest, stdev → ta.stdev.

v4 → v5

Verified

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

  • Line 1: //@version=4 → //@version=5
  • Line 9: input(type = input.integer) → input.int()
  • Line 10: input(type = input.float) → input.float()
  • Line 13: input(type = input.bool) → input.bool()
  • Line 14: input(type = input.bool) → input.bool()
  • Line 15: input(type = input.bool) → input.bool()
86 more edits
  • Line 16: input(type = input.bool) → input.bool()
  • Line 17: input(type = input.bool) → input.bool()
  • Line 25: input(type = input.bool) → input.bool()
  • Line 26: input(type = input.bool) → input.bool()
  • Line 43: input(type = input.bool) → input.bool()
  • Line 46: ema → ta.ema
  • Line 47: ema → ta.ema
  • Line 48: ema → ta.ema
  • Line 49: ema → ta.ema
  • Line 50: ema → ta.ema
  • Line 51: ema → ta.ema
  • Line 57: ema → ta.ema
  • Line 58: ema → ta.ema
  • Line 59: ema → ta.ema
  • Line 60: ema → ta.ema
  • Line 61: ema → ta.ema
  • Line 62: ema → ta.ema
  • Line 69: sma → ta.sma
  • Line 69: tr → ta.tr
  • Line 70: atr → ta.atr
  • Line 74: sum → math.sum
  • Line 75: sum → math.sum
  • Line 78: abs → math.abs
  • Line 78: abs → math.abs
  • Line 82: round → math.round
  • Line 84: ema → ta.ema
  • Line 85: linreg → ta.linreg
  • Line 86: linreg → ta.linreg
  • Line 88: linreg → ta.linreg
  • Line 92: sma → ta.sma
  • Line 95: ema → ta.ema
  • Line 98: wma → ta.wma
  • Line 101: sma → ta.sma
  • Line 101: sma → ta.sma
  • Line 101: ceil → math.ceil
  • Line 101: floor → math.floor
  • Line 124: max → math.max
  • Line 127: min → math.min
  • Line 133: round → math.round
  • Line 135: ema → ta.ema
  • Line 139: sum → math.sum
  • Line 140: sum → math.sum
  • Line 143: abs → math.abs
  • Line 143: abs → math.abs
  • Line 155: iff(c, a, b) → (c ? a : b)
  • Line 155: max → math.max
  • Line 155: iff(c, a, b) → (c ? a : b)
  • Line 155: min → math.min
  • Line 155: iff(c, a, b) → (c ? a : b)
  • Line 156: crossover → ta.crossover
  • Line 157: crossunder → ta.crossunder
  • Line 158: iff(c, a, b) → (c ? a : b)
  • Line 158: iff(c, a, b) → (c ? a : b)
  • Line 166: ema → ta.ema
  • Line 167: ema → ta.ema
  • Line 168: ema → ta.ema
  • Line 169: ema → ta.ema
  • Line 170: ema → ta.ema
  • Line 171: ema → ta.ema
  • Line 180: ema → ta.ema
  • Line 181: ema → ta.ema
  • Line 184: avg → math.avg
  • Line 185: ema → ta.ema
  • Line 185: highest → ta.highest
  • Line 186: ema → ta.ema
  • Line 186: lowest → ta.lowest
  • Line 187: avg → math.avg
  • Line 188: avg → math.avg
  • Line 189: avg → math.avg
  • Line 197: ema → ta.ema
  • Line 198: ema → ta.ema
  • Line 200: ema → ta.ema
  • Line 201: stdev → ta.stdev
  • Line 207: crossunder → ta.crossunder
  • Line 207: crossunder → ta.crossunder
  • Line 208: transp = 0 → color.new(color.aqua, 0)
  • Line 213: transp = 100 → color.new(color.red, 100)
  • Line 214: crossover → ta.crossover
  • Line 215: transp = 0 → color.new(color.green, 0)
  • Line 216: crossunder → ta.crossunder
  • Line 217: transp = 0 → color.new(color.red, 0)
  • Line 218: crossover → ta.crossover
  • Line 219: transp = 0 → color.new(#0F18BF, 0)
  • Line 220: crossunder → ta.crossunder
  • Line 221: transp = 0 → color.new(#0F18BF, 0)
  • Line 242: transp = 0 → color.new(color.lime, 0)
-//@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(13, "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=false)+showsupport = input.bool(title="Show Moving Average?", defval=false)-showsignalsk = input(title="Show Buy sell signals?", type=input.bool, defval=true)+showsignalsk = input.bool(title="Show Buy sell signals?", defval=true)-showsignalsc = input(title="Show Price/Pmax cross signals?", type=input.bool, defval=false)+showsignalsc = input.bool(title="Show Price/Pmax cross signals?", defval=false)-highlighting = input(title="Cloud On/Off?", type=input.bool, defval=false)+highlighting = input.bool(title="Cloud On/Off?", defval=false)baslik4 = input(title="-------------------- T3 Setttings --------------------", defval=false)⋯a12 = input(0.618, "T3 Fibo Volume Factor")-T31Show = input(title="Show T3?", type=input.bool, defval=false)+T31Show = input.bool(title="Show T3?", defval=false)-T32Show = input(title= "T3 Filter On/Off?", type=input.bool, defval=false)+T32Show = input.bool(title= "T3 Filter On/Off?", defval=false)T3FiboLine = input(false, title="T3 Fibonacci Lines?")⋯mav1 = input(title="Moving Average Type", defval="ZLEMA", options=["VAR","ZLEMA"])-plotbuysell = input(true, "Buy/Sell Shapes On/Off ?", input.bool)+plotbuysell = input.bool(true, "Buy/Sell Shapes On/Off ?")  ///T3 1&2-e1 = ema((high + low + 2 * close) / 4, length1)+e1 = ta.ema((high + low + 2 * close) / 4, length1)-e2 = ema(e1, length1)+e2 = ta.ema(e1, length1)-e3 = ema(e2, length1)+e3 = ta.ema(e2, length1)-e4 = ema(e3, length1)+e4 = ta.ema(e3, length1)-e5 = ema(e4, length1)+e5 = ta.ema(e4, length1)-e6 = ema(e5, length1)+e6 = ta.ema(e5, length1)c1 = -a1 * a1 * a1⋯T3 = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3-e13 = ema((high + low + 2 * close) / 4, length2)+e13 = ta.ema((high + low + 2 * close) / 4, length2)-e23 = ema(e13, length2)+e23 = ta.ema(e13, length2)-e33 = ema(e23, length2)+e33 = ta.ema(e23, length2)-e43 = ema(e33, length2)+e43 = ta.ema(e33, length2)-e53 = ema(e43, length2)+e53 = ta.ema(e43, length2)-e63 = ema(e53, length2)+e63 = ta.ema(e53, length2)c13 = -a13 * a13 * a13⋯///PMax-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⋯///MOST-zxLag1 = AP2/2==round(AP2/2) ? AP2/2 : (AP2 - 1) / 2+zxLag1 = AP2/2==math.round(AP2/2) ? AP2/2 : (AP2 - 1) / 2zxEMAData1 = (src_most + (src_most - src_most[zxLag1]))-ZLEMA1 = ema(zxEMAData1, AP2)+ZLEMA1 = ta.ema(zxEMAData1, AP2)valpha1=2/(AP2+1)⋯vdd2=src_most<src_most[1] ? src_most[1]-src_most : 0-vUD1=sum(vud2,9)+vUD1=math.sum(vud2,9)-vDD1=sum(vdd2,9)+vDD1=math.sum(vdd2,9)vCMO1=nz((vUD1-vDD1)/(vUD1+vDD1))VAR1=0.0-VAR1 := nz(valpha1*abs(vCMO1)*src_most)+(1-valpha1*abs(vCMO1))*nz(VAR1[1])+VAR1 := nz(valpha1*math.abs(vCMO1)*src_most)+(1-valpha1*math.abs(vCMO1))*nz(VAR1[1])getMA1(src, length) =>⋯Trail2 = 0.0-Trail2 := iff(Trail1>nz(Trail2[1],0) and Trail1[1]>nz(Trail2[1],0),max(nz(Trail2[1],0),Trail1-SL2),iff(Trail1<nz(Trail2[1],0) and Trail1[1]<nz(Trail2[1],0),min(nz(Trail2[1],0),Trail1+SL2),iff(Trail1>nz(Trail2[1],0),Trail1-SL2,Trail1+SL2)))+Trail2 := (Trail1>nz(Trail2[1],0) and Trail1[1]>nz(Trail2[1],0) ? math.max(nz(Trail2[1],0),Trail1-SL2) : (Trail1<nz(Trail2[1],0) and Trail1[1]<nz(Trail2[1],0) ? math.min(nz(Trail2[1],0),Trail1+SL2) : (Trail1>nz(Trail2[1],0) ? Trail1-SL2 : Trail1+SL2)))-Buy = crossover(Trail1, Trail2)+Buy = ta.crossover(Trail1, Trail2)-Sell = crossunder(Trail1, Trail2)+Sell = ta.crossunder(Trail1, Trail2)-SR=(iff(Trail1 > Trail2 ,1, iff(Trail2 > Trail1,-1,0)))+SR=((Trail1 > Trail2 ? 1 : (Trail2 > Trail1 ? -1 : 0)))////T3 TILLSON 1⋯color_4 = col4 ? color.green : col5 ? color.red : color.yellow-e12 = ema((high + low + 2 * close) / 4, length12)+e12 = ta.ema((high + low + 2 * close) / 4, length12)-e22 = ema(e12, length12)+e22 = ta.ema(e12, length12)-e32 = ema(e22, length12)+e32 = ta.ema(e22, length12)-e42 = ema(e32, length12)+e42 = ta.ema(e32, length12)-e52 = ema(e42, length12)+e52 = ta.ema(e42, length12)-e62 = ema(e52, length12)+e62 = ta.ema(e52, length12)c12 = -a12 * a12 * a12⋯///TP BB ve SNAKE-h = ema(high, len)+h = ta.ema(high, len)-l = ema(low, len)+l = ta.ema(low, len)hp = h / h[len]lp = l / l[len]-avg = avg(hp, lp)+avg = math.avg(hp, lp)-havg = ema(highest(avg, len), len)+havg = ta.ema(ta.highest(avg, len), len)-lavg = ema(lowest(avg, len), len)+lavg = ta.ema(ta.lowest(avg, len), len)-avg2 = avg(havg, lavg)+avg2 = math.avg(havg, lavg)-avg3 = avg(havg, avg2)+avg3 = math.avg(havg, avg2)-avg4 = avg(havg, avg3)+avg4 = math.avg(havg, avg3)dif = havg - avg2⋯banda_inf = 0.0-m_rapida = ema(close,rapida)+m_rapida = ta.ema(close,rapida)-m_lenta = ema(close,lenta)+m_lenta = ta.ema(close,lenta)BBMacd = m_rapida - m_lenta-Avg = ema(BBMacd,9)+Avg = ta.ema(BBMacd,9)-SDev := stdev(BBMacd,9)+SDev := ta.stdev(BBMacd,9)banda_supe := Avg + stdv * SDev⋯TS2 = plot(Trail2, "Most", style=plot.style_line,color=Trail1 > Trail2 ? color.green : color.red, linewidth=2)-tp1 = tpfiltre ? crossunder(BBMacd,banda_supe)  and (avg>avg2) and (MAvg>PMax) and nz(MAvg[10]) > nz(PMax[10]) : crossunder(BBMacd,banda_supe)  and (avg>avg4) and (MAvg>PMax) and nz(MAvg[15]) > nz(PMax[15])+tp1 = tpfiltre ? ta.crossunder(BBMacd,banda_supe)  and (avg>avg2) and (MAvg>PMax) and nz(MAvg[10]) > nz(PMax[10]) : ta.crossunder(BBMacd,banda_supe)  and (avg>avg4) and (MAvg>PMax) and nz(MAvg[15]) > nz(PMax[15])-plotshape(tp1 and tp1show, title="TP1", text="TP1", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.aqua, textcolor=color.white,transp=0) +plotshape(tp1 and tp1show, title="TP1", text="TP1", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.new(color.aqua, 0), textcolor=color.white) plot(T31Show ? T3 : na, color=color_1, linewidth=3, title="T3")⋯plot(showsupport ? MAvg : na, color=#0585E1, linewidth=2, title="Moving Avg Line")-pALL=plot(PMax, color=color.red, linewidth=2, title="PMax", transp=100)+pALL=plot(PMax, color=color.new(color.red, 100), linewidth=2, title="PMax")-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-Price", 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-Price", 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-Price", 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-Price", 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)⋯plotshape(exitlevel==5 and tplevelshow , text='5', location=location.belowbar, style=shape.triangledown, color=color.red)-plotshape(nz(tplevel[1])==2 and Sell and exitlevel>=2, title="TP", text="TP", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.lime, textcolor=color.white,transp=0)+plotshape(nz(tplevel[1])==2 and Sell and exitlevel>=2, title="TP", text="TP", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.new(color.lime, 0), textcolor=color.white)if (buySignalk)⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 7: input() → input.bool()
  • Line 8: input() → input.source()
  • Line 11: input() → input.string()
  • Line 12: input() → input.int()
  • Line 18: input() → input.bool()
  • Line 19: input() → input.int()
19 more edits
  • Line 20: input() → input.int()
  • Line 21: input() → input.float()
  • Line 23: input() → input.int()
  • Line 24: input() → input.float()
  • Line 27: input() → input.bool()
  • Line 29: input() → input.bool()
  • Line 30: input() → input.int()
  • Line 31: input() → input.int()
  • Line 32: input() → input.int()
  • Line 33: input() → input.int()
  • Line 34: input() → input.float()
  • Line 35: input() → input.bool()
  • Line 36: input() → input.bool()
  • Line 37: input() → input.bool()
  • Line 38: input() → input.bool()
  • Line 39: input() → input.source()
  • Line 40: input() → input.int()
  • Line 41: input() → input.int()
  • Line 42: input() → input.string()
⋯strategy("Y-Profit Maximizer Strategy with Exit Points", shorttitle="Y-PMax Strategy with Exit Points", overlay=true, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency=currency.USD, commission_value=0.1, commission_type=strategy.commission.percent)-baslik1 = input(title="-------------------- PMax Setttings -------------------", defval=false)+baslik1 = input.bool(title="-------------------- PMax Setttings -------------------", defval=false)-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(13, "Moving Average Length", minval=1)+length =input.int(13, "Moving Average Length", minval=1)changeATR= input.bool(title="Change ATR calculation Method?", defval=true)⋯highlighting = input.bool(title="Cloud On/Off?", defval=false)-baslik4 = input(title="-------------------- T3 Setttings --------------------", defval=false)+baslik4 = input.bool(title="-------------------- T3 Setttings --------------------", defval=false)-length1 = input(89, "T3 Length")+length1 = input.int(89, "T3 Length")-length2 = input(5, "T3 Filter Length")+length2 = input.int(5, "T3 Filter Length")-a1 = input(0.84, "T3 Volume Factor")+a1 = input.float(0.84, "T3 Volume Factor")a13 = 0.84-length12 = input(5, "Fibo T3 Length")+length12 = input.int(5, "Fibo T3 Length")-a12 = input(0.618, "T3 Fibo Volume Factor")+a12 = input.float(0.618, "T3 Fibo Volume Factor")T31Show = input.bool(title="Show T3?", defval=false)T32Show = input.bool(title= "T3 Filter On/Off?", defval=false)-T3FiboLine = input(false, title="T3 Fibonacci Lines?")+T3FiboLine = input.bool(false, title="T3 Fibonacci Lines?")shownum = true-baslik7 = input(title="---------------- Take Profit Setttings --------------", defval=false)+baslik7 = input.bool(title="---------------- Take Profit Setttings --------------", defval=false)-len = input(25, "Snake Length")+len = input.int(25, "Snake Length")-domcycle = input(20, minval=10, title="Dominant Cycle Length")+domcycle = input.int(20, minval=10, title="Dominant Cycle Length")-rapida = input(8, "Fast Avg")+rapida = input.int(8, "Fast Avg")-lenta = input(26, "Slow Avg")+lenta = input.int(26, "Slow Avg")-stdv = input(0.8, "Length")+stdv = input.float(0.8, "Length")-tpfiltre = input(false, title="TP Filter avg2/avg4?")+tpfiltre = input.bool(false, title="TP Filter avg2/avg4?")-tplevelshow = input(false, title="TP Level and Exit Level Count On/Off?")+tplevelshow = input.bool(false, title="TP Level and Exit Level Count On/Off?")-tp1show =  input(false, title="Early TP Signals On/Off ?")+tp1show =  input.bool(false, title="Early TP Signals On/Off ?")-baslik8 = input(title="------------------- MOST Setttings ------------------", defval=false)+baslik8 = input.bool(title="------------------- MOST Setttings ------------------", defval=false)-src_most=input(close,"Source")+src_most=input.source(close,"Source")-AP2 = input(defval=8,title="Length",minval=1)+AP2 = input.int(defval=8,title="Length",minval=1)-AF2 = input(defval=2,title="Percent",minval=0.1)/100+AF2 = input.int(defval=2,title="Percent",minval=0.1)/100-mav1 = input(title="Moving Average Type", defval="ZLEMA", options=["VAR","ZLEMA"])+mav1 = input.string(title="Moving Average Type", defval="ZLEMA", options=["VAR","ZLEMA"])plotbuysell = input.bool(true, "Buy/Sell Shapes On/Off ?")⋯

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L222: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
-------------------- PMax Setttings -------------------falseboolunused
Sourcehl2sourcevud1 vdd1 VAR WWMA zxEMAData lrc lrc1 TSF ma MAvg Trail1 buySignalc sellSignallc
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 91 line 94 line 97 line 100 line 103 line 106 line 109 line 112 line 116
Moving Average Length13int · min 1valpha wwalpha zxLag ZLEMA lrc lrc1 TSF ma MAvg Trail1
Change ATR calculation Method?trueboolatr
Show Moving Average?falseboolMoving Avg Line
Show Buy sell signals?trueboolBuy Sell
Show Price/Pmax cross signals?falseboolBuy-Price Sell-Price
Cloud On/Off?falseboollongFillColor shortFillColor
-------------------- T3 Setttings --------------------falseboolunused
T3 Length89inte1 e2 e3 e4 e5 e6
T3 Filter Length5inte13 e23 e33 e43 e53 e63
T3 Volume Factor0.84floatc1 c2 c3 c4
Fibo T3 Length5inte12 e22 e32 e42 e52 e62
T3 Fibo Volume Factor0.618floatc12 c22 c32 c42
Show T3?falseboolT3
T3 Filter On/Off?falseboolT3 Filter
T3 Fibonacci Lines?falseboolT3fibo
---------------- Take Profit Setttings --------------falseboolunused
Snake Length25inth l hp lp havg lavg
Dominant Cycle Length20int · min 10unused
Fast Avg8intm_rapida
Slow Avg26intm_lenta
Length0.8floatbanda_supe banda_inf
TP Filter avg2/avg4?falsebooltp1
TP Level and Exit Level Count On/Off?falseboolplotchar plotshape
Early TP Signals On/Off ?falseboolTP1
------------------- MOST Setttings ------------------falseboolunused
SourceclosesourcezxEMAData1 vud2 vdd2 VAR1
Length8int · min 1zxLag1 ZLEMA1 valpha1
Percent2int · min 0.1SL2
Moving Average TypeZLEMAstring · options ["VAR","ZLEMA"]line 146 line 149
Buy/Sell Shapes On/Off ?trueboolunused

What it calculates

  • EMA (ema, ta.ema in v5)(high + low + 2 * close) / 4, T3 Length (89)e1 · line 46
  • EMA (ema, ta.ema in v5)e1, T3 Length (89)e2 · line 47
  • EMA (ema, ta.ema in v5)e2, T3 Length (89)e3 · line 48
  • EMA (ema, ta.ema in v5)e3, T3 Length (89)e4 · line 49
  • EMA (ema, ta.ema in v5)e4, T3 Length (89)e5 · line 50
  • EMA (ema, ta.ema in v5)e5, T3 Length (89)e6 · line 51
  • EMA (ema, ta.ema in v5)(high + low + 2 * close) / 4, T3 Filter Length (5)e13 · line 57
  • EMA (ema, ta.ema in v5)e13, T3 Filter Length (5)e23 · line 58
  • EMA (ema, ta.ema in v5)e23, T3 Filter Length (5)e33 · line 59
  • EMA (ema, ta.ema in v5)e33, T3 Filter Length (5)e43 · line 60
  • EMA (ema, ta.ema in v5)e43, T3 Filter Length (5)e53 · line 61
  • EMA (ema, ta.ema in v5)e53, T3 Filter Length (5)e63 · line 62
  • SMA (sma, ta.sma in v5)tr, ATR Length (10)atr2 · line 69
  • ATR (atr, ta.atr in v5)ATR Length (10)atr · line 70
  • EMA (ema, ta.ema in v5)zxEMAData, Moving Average Length (13)ZLEMA · line 84
  • Linreg (linreg, ta.linreg in v5)Source (hl2), Moving Average Length (13), 0lrc · line 85
  • Linreg (linreg, ta.linreg in v5)Source (hl2), Moving Average Length (13), 1lrc1 · line 86
  • Linreg (linreg, ta.linreg in v5)Source (hl2), Moving Average Length (13), 0TSF · line 88
  • SMA / EMA / WMA (sma, ta.sma in v5)Source (hl2), Moving Average Length (13)ma · line 92
  • EMA (ema, ta.ema in v5)zxEMAData1, Length (8)ZLEMA1 · line 135
  • Crossover (crossover, ta.crossover in v5)Trail1, Trail2Buy · line 156
  • Crossunder (crossunder, ta.crossunder in v5)Trail1, Trail2Sell · line 157
  • EMA (ema, ta.ema in v5)(high + low + 2 * close) / 4, Fibo T3 Length (5)e12 · line 166
  • EMA (ema, ta.ema in v5)e12, Fibo T3 Length (5)e22 · line 167
  • EMA (ema, ta.ema in v5)e22, Fibo T3 Length (5)e32 · line 168
  • EMA (ema, ta.ema in v5)e32, Fibo T3 Length (5)e42 · line 169
  • EMA (ema, ta.ema in v5)e42, Fibo T3 Length (5)e52 · line 170
  • EMA (ema, ta.ema in v5)e52, Fibo T3 Length (5)e62 · line 171
  • EMA (ema, ta.ema in v5)high, Snake Length (25)h · line 180
  • EMA (ema, ta.ema in v5)low, Snake Length (25)l · line 181
  • EMA / Highest (ema, ta.ema in v5)highest(avg, len), Snake Length (25)havg · line 185
  • EMA / Lowest (ema, ta.ema in v5)lowest(avg, len), Snake Length (25)lavg · line 186
  • Stdev (stdev, ta.stdev in v5)BBMacd, 9SDev · line 201
  • EMA (ema, ta.ema in v5)close, Fast Avg (8)m_rapida · line 197
  • EMA (ema, ta.ema in v5)close, Slow Avg (26)m_lenta · line 198
  • EMA (ema, ta.ema in v5)BBMacd, 9Avg · line 200
  • Crossunder (crossunder, ta.crossunder in v5)BBMacd, banda_supetp1 · line 207
  • Crossover (crossover, ta.crossover in v5)MAvg, PMaxbuySignalk · line 214
  • Crossunder (crossunder, ta.crossunder in v5)MAvg, PMaxsellSignallk · line 216
  • Crossover (crossover, ta.crossover in v5)Source (hl2), PMaxbuySignalc · line 218
  • Crossunder (crossunder, ta.crossunder in v5)Source (hl2), PMaxsellSignallc · line 220

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

Order rules

OrderFires whenBy defaultLine
Open Buy long(buySignalk)On244
Exit Exit1 limitnz(tplevel[1])==2 and Sell and exitlevel==2On246
Exit Exit2 limitnz(tplevel[1])==3 and Sell and exitlevel==3On248
Exit Exit3 limitnz(tplevel[1])==4 and Sell and exitlevel==3On251
Exit Exit4 limitnz(tplevel[1])==5 and Sell and exitlevel==3On254
Close (sellSignallk)On256

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

Does it repaint?

No

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

4/4trades 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−1.9%+102.5%1338%0.9730.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+9.6%+5.5%1540%1.686.8%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+86.2%+9.8%1050%2.4244.7%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+20.0%+8.4%1354%2.478.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−27.1%+16.7%1242%0.6971.9%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+23.7%+21.5%1362%2.0316.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−3.8%+148.3%1250%0.9553.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+2.7%+17.1%1346%1.1911.9%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 market30%−$2,763.61
Sideways market757%$2,550.64
Falling market333%$28.77

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

How bad could the drawdown be?

43.3%

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

0%50%
All 13 trades
SideEntryExitBarsP&L
long22 May 2024 70,148.3011 Jun 2024 69,540.0020−$26.66
long22 May 2024 70,148.3022 Jun 2024 64,143.6031−$656.37
long19 Jul 2024 63,987.906 Aug 2024 54,018.8018−$1,576.41
long22 Sep 2024 63,349.0024 Oct 2024 66,668.6032$125.88
long22 Sep 2024 63,349.0014 Jan 2025 94,536.10114$3,673.61
long22 Jan 2025 106,144.0027 Feb 2025 84,250.1036−$2,080.58
long26 Apr 2025 94,638.7018 May 2025 103,127.0022$219.00
long26 Apr 2025 94,638.7029 Aug 2025 112,567.00125$1,404.37
long4 Oct 2025 122,232.0013 Oct 2025 114,959.009−$614.45
long17 Jan 2026 95,550.9025 Jan 2026 89,225.308−$681.35
long15 Apr 2026 74,131.6016 May 2026 79,113.2031$162.83
long15 Apr 2026 74,131.6029 May 2026 73,617.5044−$66.95
long24 Jul 2026 65,099.0013 Aug 2026 63,480.0020−$67.11

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
Y-Profit Maximizer Strategy with Exit Points this page—v4 strategy−1.9%1330.4%
BTC 15 min by RafaelZionisma ema wma linreg stdev highest lowestv4 strategy−25.7%11938.9%
Multi MA Trend Following Strategy Template by TradeAutomationema linreg sma wma stdev atr highest lowestv5 strategy+12.3%326.9%
CHOP Zone Entry Strategy + DMI-PSAR Exit by IronCasperatr highest lowest sma linreg emav4 strategy+17.1%820.0%
[fpemehd] SSL Baseline Strategy by DuDu95ema sma highest lowest stdev atrv5 strategy+2.3%713.7%
SSL + Wave Trend Strategy by kevinmck100ema sma highest lowest stdev atrv5 strategy−1.0%11.0%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 179 msYes 1,000 bars in 218 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.

//@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: @enesyetkinstrategy("Y-Profit Maximizer Strategy with Exit Points", shorttitle="Y-PMax Strategy with Exit Points", overlay=true, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency=currency.USD, commission_value=0.1, commission_type=strategy.commission.percent)baslik1 = input(title="-------------------- PMax Setttings -------------------", defval=false)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(13, "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=false)showsignalsk = input(title="Show Buy sell signals?", type=input.bool, defval=true)showsignalsc = input(title="Show Price/Pmax cross signals?", type=input.bool, defval=false)highlighting = input(title="Cloud On/Off?", type=input.bool, defval=false)baslik4 = input(title="-------------------- T3 Setttings --------------------", defval=false)length1 = input(89, "T3 Length")length2 = input(5, "T3 Filter Length")a1 = input(0.84, "T3 Volume Factor")a13 = 0.84length12 = input(5, "Fibo T3 Length")a12 = input(0.618, "T3 Fibo Volume Factor")T31Show = input(title="Show T3?", type=input.bool, defval=false)T32Show = input(title= "T3 Filter On/Off?", type=input.bool, defval=false)T3FiboLine = input(false, title="T3 Fibonacci Lines?")shownum = truebaslik7 = input(title="---------------- Take Profit Setttings --------------", defval=false)len = input(25, "Snake Length")domcycle = input(20, minval=10, title="Dominant Cycle Length")rapida = input(8, "Fast Avg")lenta = input(26, "Slow Avg")stdv = input(0.8, "Length")tpfiltre = input(false, title="TP Filter avg2/avg4?")tplevelshow = input(false, title="TP Level and Exit Level Count On/Off?")tp1show =  input(false, title="Early TP Signals On/Off ?")baslik8 = input(title="------------------- MOST Setttings ------------------", defval=false)src_most=input(close,"Source")AP2 = input(defval=8,title="Length",minval=1)AF2 = input(defval=2,title="Percent",minval=0.1)/100mav1 = input(title="Moving Average Type", defval="ZLEMA", options=["VAR","ZLEMA"])plotbuysell = input(true, "Buy/Sell Shapes On/Off ?", input.bool)  ///T3 1&2e1 = ema((high + low + 2 * close) / 4, length1)e2 = ema(e1, length1)e3 = ema(e2, length1)e4 = ema(e3, length1)e5 = ema(e4, length1)e6 = ema(e5, length1)c1 = -a1 * a1 * a1c2 = 3 * a1 * a1 + 3 * a1 * a1 * a1c3 = -6 * a1 * a1 - 3 * a1 - 3 * a1 * a1 * a1c4 = 1 + 3 * a1 + a1 * a1 * a1 + 3 * a1 * a1T3 = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3e13 = ema((high + low + 2 * close) / 4, length2)e23 = ema(e13, length2)e33 = ema(e23, length2)e43 = ema(e33, length2)e53 = ema(e43, length2)e63 = ema(e53, length2)c13 = -a13 * a13 * a13c23 = 3 * a13 * a13 + 3 * a13 * a13 * a13c33 = -6 * a13 * a13 - 3 * a13 - 3 * a13 * a13 * a13c43 = 1 + 3 * a13 + a13 * a13 * a13 + 3 * a13 * a13T33 = c13 * e63 + c23 * e53 + c33 * e43 + c43 * e33///PMaxatr2 = 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        if mav == "T3"        ma := T3        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: shortStop///MOSTzxLag1 = AP2/2==round(AP2/2) ? AP2/2 : (AP2 - 1) / 2zxEMAData1 = (src_most + (src_most - src_most[zxLag1]))ZLEMA1 = ema(zxEMAData1, AP2)valpha1=2/(AP2+1)vud2=src_most>src_most[1] ? src_most-src_most[1] : 0vdd2=src_most<src_most[1] ? src_most[1]-src_most : 0vUD1=sum(vud2,9)vDD1=sum(vdd2,9)vCMO1=nz((vUD1-vDD1)/(vUD1+vDD1))VAR1=0.0VAR1 := nz(valpha1*abs(vCMO1)*src_most)+(1-valpha1*abs(vCMO1))*nz(VAR1[1])getMA1(src, length) =>    ma1 = 0.0    if mav1 == "VAR"        ma1 := VAR1        ma1    if mav1 == "ZLEMA"        ma1 := ZLEMA1        ma1Trail1 = getMA1(src, length)SL2 = Trail1*AF2 // Stop LossTrail2 = 0.0Trail2 := iff(Trail1>nz(Trail2[1],0) and Trail1[1]>nz(Trail2[1],0),max(nz(Trail2[1],0),Trail1-SL2),iff(Trail1<nz(Trail2[1],0) and Trail1[1]<nz(Trail2[1],0),min(nz(Trail2[1],0),Trail1+SL2),iff(Trail1>nz(Trail2[1],0),Trail1-SL2,Trail1+SL2)))Buy = crossover(Trail1, Trail2)Sell = crossunder(Trail1, Trail2)SR=(iff(Trail1 > Trail2 ,1, iff(Trail2 > Trail1,-1,0)))////T3 TILLSON 1col1 = T3 > T3[1]col3 = T3 < T3[1]col4 = T33 > T33[1]col5 = T33 < T33[1]color_1 = col1 ? color.green : col3 ? color.red : color.yellowcolor_4 = col4 ? color.green : col5 ? color.red : color.yellowe12 = ema((high + low + 2 * close) / 4, length12)e22 = ema(e12, length12)e32 = ema(e22, length12)e42 = ema(e32, length12)e52 = ema(e42, length12)e62 = ema(e52, length12)c12 = -a12 * a12 * a12c22 = 3 * a12 * a12 + 3 * a12 * a12 * a12c32 = -6 * a12 * a12 - 3 * a12 - 3 * a12 * a12 * a12c42 = 1 + 3 * a12 + a12 * a12 * a12 + 3 * a12 * a12T32 = c12 * e62 + c22 * e52 + c32 * e42 + c42 * e32col12 = T32 > T32[1]col32 = T32 < T32[1]///TP BB ve SNAKEh = ema(high, len)l = ema(low, len)hp = h / h[len]lp = l / l[len]avg = avg(hp, lp)havg = ema(highest(avg, len), len)lavg = ema(lowest(avg, len), len)avg2 = avg(havg, lavg)avg3 = avg(havg, avg2)avg4 = avg(havg, avg3)dif = havg - avg2ust = havg + difalt = lavg - dif///BB on MACDSDev = 0.0banda_supe = 0.0banda_inf = 0.0m_rapida = ema(close,rapida)m_lenta = ema(close,lenta)BBMacd = m_rapida - m_lentaAvg = ema(BBMacd,9)SDev := stdev(BBMacd,9)banda_supe := Avg + stdv * SDevbanda_inf := Avg - stdv * SDevcolor2 = col12 ? color.blue : col32 ? color.purple : color.yellowTS1 = plot(Trail1, "ExMov", style=plot.style_line,color=Trail1 > Trail2 ? color.blue : color.yellow, linewidth=2)TS2 = plot(Trail2, "Most", style=plot.style_line,color=Trail1 > Trail2 ? color.green : color.red, linewidth=2)tp1 = tpfiltre ? crossunder(BBMacd,banda_supe)  and (avg>avg2) and (MAvg>PMax) and nz(MAvg[10]) > nz(PMax[10]) : crossunder(BBMacd,banda_supe)  and (avg>avg4) and (MAvg>PMax) and nz(MAvg[15]) > nz(PMax[15])plotshape(tp1 and tp1show, title="TP1", text="TP1", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.aqua, textcolor=color.white,transp=0) plot(T31Show ? T3 : na, color=color_1, linewidth=3, title="T3")plot(T32Show ? T33 : na, color=color_4, linewidth=3, title="T3 Filter")plot(T3FiboLine and T32 ? T32 : na, color=color2, linewidth=2, title="T3fibo")plot(showsupport ? MAvg : na, color=#0585E1, linewidth=2, title="Moving Avg Line")pALL=plot(PMax, color=color.red, linewidth=2, title="PMax", transp=100)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-Price", 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-Price", 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="Up Trend Cloud", color=longFillColor)fill(mPlot, pALL, title="Down Trend Cloud", color=shortFillColor)tplevel = 0//tplevel := tp1 ? nz(tplevel[1])==0 ? 1 : nz(tplevel[1])==1 ? 2 : 0 : nz(tplevel[1])==0 ? 0 : nz(tplevel[1])==1 ? 1 : nz(tplevel[1])==2 ? 2 : sellSignallk ? 0 : 0//tplevel := sellSignallk or MAvg < PMax ? 0 : tp1 and nz(tplevel[1])==8 ? 9 : tp1 and nz(tplevel[1])==7 ? 8 : tp1 and nz(tplevel[1])==6 ? 7 : tp1 and nz(tplevel[1])==5 ? 6 : tp1 and nz(tplevel[1])==4 ? 5 : tp1 and nz(tplevel[1])==3 ? 4 : tp1 and nz(tplevel[1])==2 ? 3 : tp1 and nz(tplevel[1])==1 ? 2 : nz(tplevel[1])==1 ? 1 : nz(tplevel[1])==2 ? 2 : nz(tplevel[1])==3 ? 3 : nz(tplevel[1])==4 ? 4 : nz(tplevel[1])==5 ? 5 : nz(tplevel[1])==6 ? 6 : nz(tplevel[1])==7 ? 7 : nz(tplevel[1])==8 ? 8 : nz(tplevel[1])==9 ? 9 : 1 tplevel := sellSignallk or MAvg < PMax ? 0 : Trail1 < Trail2 ? 0 : tp1 and nz(tplevel[1])==1 ? 2 : nz(tplevel[1])==1 ? 1 : nz(tplevel[1])==2 ? 2 : 1exitlevel = 0exitlevel := sellSignallk or MAvg < PMax ? 0 : Sell and  nz(tplevel[1])==2 and nz(exitlevel[1])==1 ? 2 : Sell and  nz(tplevel[1])==2 and nz(exitlevel[1])==2 ? 3 : Sell and  nz(tplevel[1])==2 and nz(exitlevel[1])==3 ? 4 :  Sell and  nz(tplevel[1])==2 and nz(exitlevel[1])==4 ? 5: nz(exitlevel[1])==1 ? 1  : nz(exitlevel[1])==2 ? 2 : nz(exitlevel[1])==3 ? 3 : nz(exitlevel[1])==4 ? 4 : nz(exitlevel[1])==5 ? 5:  1plotchar(tplevel==0 and tplevelshow, char='0', color=color.green)plotchar(tplevel==1 and tplevelshow , char='1', color=color.green)plotchar(tplevel==2 and tplevelshow, char='2', color=color.green) plotshape(exitlevel==0 and tplevelshow , text='0', location=location.belowbar, style=shape.triangledown, color=color.red) plotshape(exitlevel==1 and tplevelshow , text='1', location=location.belowbar, style=shape.triangledown, color=color.red) plotshape(exitlevel==2 and tplevelshow , text='2', location=location.belowbar, style=shape.triangledown, color=color.red) plotshape(exitlevel==3 and tplevelshow , text='3', location=location.belowbar, style=shape.triangledown, color=color.red)plotshape(exitlevel==4 and tplevelshow , text='4', location=location.belowbar, style=shape.triangledown, color=color.red)plotshape(exitlevel==5 and tplevelshow , text='5', location=location.belowbar, style=shape.triangledown, color=color.red)plotshape(nz(tplevel[1])==2 and Sell and exitlevel>=2, title="TP", text="TP", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.lime, textcolor=color.white,transp=0)if (buySignalk)    strategy.entry("Buy", strategy.long)if nz(tplevel[1])==2 and Sell and exitlevel==2     strategy.exit ("Exit1", from_entry="Buy", limit=close, qty_percent = 25)if nz(tplevel[1])==3 and Sell and exitlevel==3    strategy.exit ("Exit2", from_entry="Buy", limit=close, qty_percent = 33.3)    if nz(tplevel[1])==4 and Sell and exitlevel==3     strategy.exit ("Exit3", from_entry="Buy", limit=close, qty_percent = 50)    if nz(tplevel[1])==5 and Sell and exitlevel==3     strategy.exit ("Exit4", from_entry="Buy", limit=close)  if (sellSignallk)    strategy.close_all()