Pine Script v4 · Strategy
Super Z strategy - Thanks to Rafael Zioni
A Pine Script v4 strategy built on EMA (src5*volume, len5), ATR (50) and Crossover (c, st_line). 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 10000 contracts and pays no commission. 6 settings; defaults include Src5 close, Tf 1440 and Res5 D.
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 Super Z strategy - Thanks to Rafael Zioni repaint?
- Yes
- At least one pattern in the source can repaint: higher-timeframe data, intrabar recalculation.
- How did Super Z strategy - Thanks to Rafael Zioni do on BTCUSDT 1D with default settings?
- −404,823.00%
- From 26 Jan 2024 to 21 Oct 2026, over 56 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Super Z strategy - Thanks to Rafael Zioni 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 Super Z strategy - Thanks to Rafael Zioni use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Super Z strategy - Thanks to Rafael Zioni run in Zeal Terminal?
- Yes
- It compiles in 18 ms and runs 1,000 bars in 99 ms, in the browser.
BTCUSDT · 1D · default settings
- VHMA
- Plot
- Plot
- Open
- Close
- High
- Low
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −404,823.00%
- −$40,482,300.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 56
- 22 won · 34 lost
- Profitable
- 39.3%
- of closed trades
- Profit factor
- 0.97
- gross profit ÷ gross loss
- Max drawdown
- 2,951,790.00%
- −$445,528,000.00
One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A short position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
4 settings have no label
In the settings dialog src5 (line 6), tf (line 8), res5 (line 41), signal (line 72) show an empty name. The labels on this page come from the variable names.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
-
Note
Uses transp =, which v5 removed line 32
transp = on line 32, 33, 34, 47, 48, 49, 50. 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, floor → math.floor, sqrt → math.sqrt, security → request.security, atr → ta.atr, max → math.max, min → math.min, crossover → ta.crossover, crossunder → ta.crossunder.
v4 → v5
VerifiedSame 56 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 4: //@version=4 → //@version=5
- Line 13: ema → ta.ema
- Line 13: ema → ta.ema
- Line 24: floor → math.floor
- Line 25: floor → math.floor
- Line 25: sqrt → math.sqrt
18 more edits
- Line 32: transp = 60 → color.new(hu, 60)
- Line 33: transp = 80 → color.new(hu, 80)
- Line 34: transp = 70 → color.new(hu, 70)
- Line 41: input(type = input.resolution) → input.timeframe()
- Line 42: security → request.security
- Line 43: security → request.security
- Line 44: security → request.security
- Line 45: security → request.security
- Line 47: transp = 100 → color.new(col, 100)
- Line 48: transp = 100 → color.new(col, 100)
- Line 49: transp = 60 → color.new(col, 60)
- Line 50: transp = 60 → color.new(col, 60)
- Line 57: atr → ta.atr
- Line 58: atr → ta.atr
- Line 60: max → math.max
- Line 62: min → math.min
- Line 70: crossover → ta.crossover
- Line 71: crossunder → ta.crossunder
⋯//https://www.tradingview.com/script/wYknDlLx-super-Z/-//@version=4+//@version=5strategy("Super Z strategy - Thanks to Rafael Zioni", shorttitle="Super Z strategy",overlay=true,precision=6, initial_capital=10000,calc_on_every_tick=true, pyramiding=10, default_qty_type=strategy.fixed, default_qty_value=10000, currency=currency.EUR)⋯ 60 / timeframe.multiplier * 24 * 7 : 7-ma = ema(src5*volume, len5) / ema(volume, len5)+ma = ta.ema(src5*volume, len5) / ta.ema(volume, len5)//script taken from https://www.tradingview.com/script/kChCRRZI-Hull-Moving-Average/⋯ s / n-hm = 2.0 * p(src1, floor(len5 / 2)) - p(src1, len5)+hm = 2.0 * p(src1, math.floor(len5 / 2)) - p(src1, len5)-vhma = p(hm, floor(sqrt(len5)))+vhma = p(hm, math.floor(math.sqrt(len5)))lineColor = vhma > vhma[1] ? color.lime : color.red⋯ll = vhma[1]-m1 = plot(vl, color=hu, linewidth=1, transp=60)+m1 = plot(vl, color=color.new(hu, 60), linewidth=1)-m2 = plot(vis ? ll : na, color=hu, linewidth=2, transp=80)+m2 = plot(vis ? ll : na, color=color.new(hu, 80), linewidth=2)-fill(m1, m2, color=hu, transp=70)+fill(m1, m2, color=color.new(hu, 70))//⋯//-res5 = input("D", type=input.resolution)+res5 = input.timeframe("D")-o = security(syminfo.tickerid, res5, open, barmerge.gaps_off, barmerge.lookahead_on)+o = request.security(syminfo.tickerid, res5, open, barmerge.gaps_off, barmerge.lookahead_on)-c = security(syminfo.tickerid, res5, close, barmerge.gaps_off, barmerge.lookahead_on)+c = request.security(syminfo.tickerid, res5, close, barmerge.gaps_off, barmerge.lookahead_on)-hz = security(syminfo.tickerid, res5, high, barmerge.gaps_off, barmerge.lookahead_on)+hz = request.security(syminfo.tickerid, res5, high, barmerge.gaps_off, barmerge.lookahead_on)-l = security(syminfo.tickerid, res5, low, barmerge.gaps_off, barmerge.lookahead_on)+l = request.security(syminfo.tickerid, res5, low, barmerge.gaps_off, barmerge.lookahead_on)col = c >= o ? color.lime : color.red-ppo = plot(b ? o >= c ? hz : l : o, color=col, title="Open", style=plot.style_stepline, transp=100)+ppo = plot(b ? o >= c ? hz : l : o, color=color.new(col, 100), title="Open", style=plot.style_stepline)-ppc = plot(b ? o <= c ? hz : l : c, color=col, title="Close", style=plot.style_stepline, transp=100)+ppc = plot(b ? o <= c ? hz : l : c, color=color.new(col, 100), title="Close", style=plot.style_stepline)-plot(b and hz > c ? hz : na, color=col, title="High", style=plot.style_circles, linewidth=2,transp=60)+plot(b and hz > c ? hz : na, color=color.new(col, 60), title="High", style=plot.style_circles, linewidth=2)-plot(b and l < c ? l : na, color=col, title="Low", style=plot.style_circles,linewidth=2, transp=60)+plot(b and l < c ? l : na, color=color.new(col, 60), title="Low", style=plot.style_circles,linewidth=2)fill(ppo, ppc, col)⋯// CALCULATIONS //-up_lev =l - (st_mult * atr(st_period))+up_lev =l - (st_mult * ta.atr(st_period))-dn_lev = hz + (st_mult * atr(st_period))+dn_lev = hz + (st_mult * ta.atr(st_period))up_trend = 0.0-up_trend := c[1] > up_trend[1] ? max(up_lev, up_trend[1]) : up_lev+up_trend := c[1] > up_trend[1] ? math.max(up_lev, up_trend[1]) : up_levdown_trend = 0.0-down_trend := c[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev+down_trend := c[1] < down_trend[1] ? math.min(dn_lev, down_trend[1]) : dn_lev// Calculate trend var⋯//plot(st_line[1], color = trend == 1 ? color.green : color.red , style = plot.style_cross, linewidth = 2, title = "SuperTrend")-buy=crossover( c, st_line)+buy=ta.crossover( c, st_line)-sell=crossunder(c, st_line)+sell=ta.crossunder(c, st_line)signal=input(false)⋯Same 56 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: input() → input.source()
- Line 8: input() → input.int()
- Line 54: input() → input.int()
- Line 55: input() → input.int()
- Line 72: input() → input.bool()
⋯strategy("Super Z strategy - Thanks to Rafael Zioni", shorttitle="Super Z strategy",overlay=true,precision=6, initial_capital=10000,calc_on_every_tick=true, pyramiding=10, default_qty_type=strategy.fixed, default_qty_value=10000, currency=currency.EUR)-src5 = input(close)+src5 = input.source(close) -tf = input(1440)+tf = input.int(1440)len5 = timeframe.isintraday and timeframe.multiplier >= 1 ? ⋯// INPUTS //-st_mult = input(1, title = 'SuperTrend Multiplier', minval = 0, maxval = 100, step = 0.01)+st_mult = input.int(1, title = 'SuperTrend Multiplier', minval = 0, maxval = 100, step = 0.01)-st_period = input(50, title = 'SuperTrend Period', minval = 1)+st_period = input.int(50, title = 'SuperTrend Period', minval = 1)// CALCULATIONS //⋯sell=ta.crossunder(c, st_line)-signal=input(false)+signal=input.bool(false)/////////////// Plotting /////////////// ⋯Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 56 before, 0 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯//https://www.tradingview.com/script/wYknDlLx-super-Z/-//@version=5+//@version=6strategy("Super Z strategy - Thanks to Rafael Zioni", shorttitle="Super Z strategy",overlay=true,precision=6, initial_capital=10000,calc_on_every_tick=true, pyramiding=10, default_qty_type=strategy.fixed, default_qty_value=10000, currency=currency.EUR)⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Src5 (no label in the script) | close | source | ma s |
| Tf (no label in the script) | 1440 | int | len5 |
| Res5 (no label in the script) | D | timeframe (written input.resolution) | o c hz l |
| SuperTrend Multiplier | 1 | int · min 0 · max 100 · step 0.01 | up_lev dn_lev |
| SuperTrend Period | 50 | int · min 1 | up_lev dn_lev |
| Signal (no label in the script) | false | bool | plotshape |
What it calculates
- EMA (
ema,ta.emain v5)src5*volume, len5ma · line 13 - ATR (
atr,ta.atrin v5)SuperTrend Period (50)up_lev · line 57 - ATR (
atr,ta.atrin v5)SuperTrend Period (50)dn_lev · line 58 - Crossover (
crossover,ta.crossoverin v5)c, st_linebuy · line 70 - Crossunder (
crossunder,ta.crossunderin v5)c, st_linesell · line 71
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open My Long Entry Id long | (buy) | On | 77 |
| Open My Short Entry Id short | (sell) | On | 79 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
Yes
At least one pattern in the source can repaint; it is marked Check below.
- CheckHigher-timeframe data4 security call(s) use lookahead_on (line 42, 43, 44, 45). Without a [1] offset this reads future bars in history.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- CheckIntrabar recalculationcalc_on_every_tick = true. Live values can differ from history.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −404,823.0% | +102.5% | 56 | 39% | 0.97 | 2,951,790.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +5,627,720.0% | +5.5% | 19 | 84% | 38.84 | 141,290.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −245,494.0% | +9.8% | 62 | 31% | 0.77 | 447,221.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +243,315.0% | +8.4% | 17 | 94% | 30.21 | 1,643.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −14,054.0% | +16.7% | 60 | 38% | 0.75 | 10,237.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +11,086.0% | +21.5% | 19 | 89% | 70.29 | 190.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +4,633.0% | +148.3% | 54 | 39% | 1.03 | 34,630.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +56,917.0% | +17.1% | 21 | 71% | 11.18 | 5,214.0% | 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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 22 | 32% | −$429,832,000.00 |
| Sideways market | 24 | 54% | $490,342,000.00 |
| Falling market | 10 | 20% | −$100,992,000.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
7,251,120.0%
The 95th percentile of the worst drawdown when the same 56 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 153.0% to 7,251,120.0%; the tick is what actually happened, 2,621,010.0%. Order luck alone moves it this much.
All 56 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 20 Mar 2024 61,937.40 | 26 Mar 2024 69,880.00 | 6 | −$79,425,900.00 |
| long | 26 Mar 2024 69,880.00 | 3 Apr 2024 65,464.00 | 8 | −$44,160,100.00 |
| short | 3 Apr 2024 65,464.00 | 9 Apr 2024 71,620.00 | 6 | −$61,560,100.00 |
| long | 9 Apr 2024 71,620.00 | 14 Apr 2024 63,924.50 | 5 | −$76,954,800.00 |
| short | 14 Apr 2024 63,924.50 | 4 May 2024 62,882.00 | 20 | $10,425,100.00 |
| long | 4 May 2024 62,882.00 | 12 Jun 2024 67,314.20 | 39 | $44,322,200.00 |
| short | 12 Jun 2024 67,314.20 | 15 Jul 2024 60,797.90 | 33 | $65,163,200.00 |
| long | 15 Jul 2024 60,797.90 | 1 Aug 2024 64,628.00 | 17 | $38,301,000.00 |
| short | 1 Aug 2024 64,628.00 | 9 Aug 2024 61,686.00 | 8 | $29,420,100.00 |
| long | 9 Aug 2024 61,686.00 | 28 Aug 2024 59,415.00 | 19 | −$22,710,000.00 |
| short | 28 Aug 2024 59,415.00 | 11 Sep 2024 57,636.00 | 14 | $17,790,100.00 |
| long | 11 Sep 2024 57,636.00 | 2 Oct 2024 60,804.90 | 21 | $31,689,300.00 |
| short | 2 Oct 2024 60,804.90 | 15 Oct 2024 66,084.00 | 13 | −$52,790,800.00 |
| long | 15 Oct 2024 66,084.00 | 4 Nov 2024 68,776.00 | 20 | $26,919,900.00 |
| short | 4 Nov 2024 68,776.00 | 7 Nov 2024 75,572.00 | 3 | −$67,960,000.00 |
| long | 7 Nov 2024 75,572.00 | 26 Nov 2024 93,010.00 | 19 | $174,380,000.00 |
| short | 26 Nov 2024 93,010.00 | 5 Dec 2024 98,587.30 | 9 | −$55,773,100.00 |
| long | 5 Dec 2024 98,587.30 | 19 Dec 2024 100,204.00 | 14 | $16,166,900.00 |
| short | 19 Dec 2024 100,204.00 | 7 Jan 2025 102,236.00 | 19 | −$20,315,900.00 |
| long | 7 Jan 2025 102,236.00 | 10 Jan 2025 92,552.50 | 3 | −$96,831,100.00 |
| short | 10 Jan 2025 92,552.50 | 16 Jan 2025 100,497.00 | 6 | −$79,448,600.00 |
| long | 16 Jan 2025 100,497.00 | 3 Feb 2025 97,700.60 | 18 | −$27,967,600.00 |
| short | 3 Feb 2025 97,700.60 | 3 Mar 2025 94,270.00 | 28 | $34,306,000.00 |
| long | 3 Mar 2025 94,270.00 | 10 Mar 2025 80,734.50 | 7 | −$135,355,000.00 |
| short | 10 Mar 2025 80,734.50 | 13 Apr 2025 85,276.90 | 34 | −$45,424,300.00 |
| long | 13 Apr 2025 85,276.90 | 30 May 2025 105,590.00 | 47 | $203,128,000.00 |
| short | 30 May 2025 105,590.00 | 10 Jun 2025 110,263.00 | 11 | −$46,732,700.00 |
| long | 10 Jun 2025 110,263.00 | 18 Jun 2025 104,551.00 | 8 | −$57,118,500.00 |
| short | 18 Jun 2025 104,551.00 | 26 Jun 2025 107,341.00 | 8 | −$27,894,200.00 |
| long | 26 Jun 2025 107,341.00 | 1 Aug 2025 115,764.00 | 36 | $84,234,800.00 |
| short | 1 Aug 2025 115,764.00 | 8 Aug 2025 117,472.00 | 7 | −$17,079,500.00 |
| long | 8 Aug 2025 117,472.00 | 20 Aug 2025 112,873.00 | 12 | −$45,990,700.00 |
| short | 20 Aug 2025 112,873.00 | 9 Sep 2025 112,065.00 | 20 | $8,077,200.00 |
| long | 9 Sep 2025 112,065.00 | 23 Sep 2025 112,651.00 | 14 | $5,857,600.00 |
| short | 23 Sep 2025 112,651.00 | 30 Sep 2025 114,312.00 | 7 | −$16,609,800.00 |
| long | 30 Sep 2025 114,312.00 | 11 Oct 2025 112,774.00 | 11 | −$15,374,800.00 |
| short | 11 Oct 2025 112,774.00 | 25 Oct 2025 111,005.00 | 14 | $17,695,900.00 |
| long | 25 Oct 2025 111,005.00 | 30 Oct 2025 110,021.00 | 5 | −$9,836,000.00 |
| short | 30 Oct 2025 110,021.00 | 27 Nov 2025 90,484.00 | 28 | $195,373,000.00 |
| long | 27 Nov 2025 90,484.00 | 2 Dec 2025 86,286.00 | 5 | −$41,980,000.00 |
| short | 2 Dec 2025 86,286.00 | 5 Jan 2026 91,529.70 | 34 | −$52,437,300.00 |
| long | 5 Jan 2026 91,529.70 | 21 Jan 2026 88,427.70 | 16 | −$31,020,800.00 |
| short | 21 Jan 2026 88,427.70 | 3 Mar 2026 68,830.10 | 41 | $195,976,000.00 |
| long | 3 Mar 2026 68,830.10 | 9 Mar 2026 65,971.20 | 6 | −$28,588,600.00 |
| short | 9 Mar 2026 65,971.20 | 16 Mar 2026 72,815.30 | 7 | −$68,440,500.00 |
| long | 16 Mar 2026 72,815.30 | 20 Mar 2026 69,930.00 | 4 | −$28,852,400.00 |
| short | 20 Mar 2026 69,930.00 | 8 Apr 2026 71,924.20 | 19 | −$19,942,100.00 |
| long | 8 Apr 2026 71,924.20 | 18 May 2026 77,457.70 | 40 | $55,334,500.00 |
| short | 18 May 2026 77,457.70 | 14 Jun 2026 64,458.00 | 27 | $129,997,000.00 |
| long | 14 Jun 2026 64,458.00 | 24 Jun 2026 62,734.60 | 10 | −$17,234,400.00 |
| short | 24 Jun 2026 62,734.60 | 5 Jul 2026 63,144.00 | 11 | −$4,094,400.00 |
| long | 5 Jul 2026 63,144.00 | 1 Aug 2026 62,887.90 | 27 | −$2,561,300.00 |
| short | 1 Aug 2026 62,887.90 | 20 Aug 2026 69,334.80 | 19 | −$64,469,000.00 |
| long | 20 Aug 2026 69,334.80 | 11 Sep 2026 76,568.70 | 22 | $72,339,500.00 |
| short | 11 Sep 2026 76,568.70 | 19 Sep 2026 80,883.90 | 8 | −$43,151,300.00 |
| long | 19 Sep 2026 80,883.90 | 9 Oct 2026 81,754.50 | 20 | $8,706,000.00 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Super Z strategy - Thanks to Rafael Zioni this page | — | v4 strategy | −404,823.0% | 56 | 2,951,790.0% |
| Trend Reversal - Potential pressure by BardiaB2 | atr ema | v4 strategy | +133,960.0% | 5 | 1,504.8% |
| Simple Ema_ATR Strategy HulkTrading by TheHulkTrading | ema atr | v4 strategy | +2.2% | 14 | 15.6% |
| Keltner Breakout Strategy by Zeal Terminal | ema atr | v5 strategy | +3.5% | 21 | 2.3% |
| [EKIN] ATR Exit Strategy by ekinbasarkomur | ema atr | v5 strategy | +781.7% | 30 | 2,960.8% |
| DEMA-EMA & VOLATILITY (VAMS) by Qorbanjf | ema atr | v4 strategy | +2,833,450.0% | 19 | 15,721.0% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 18 ms | With a workaround 1,000 bars in 99 ms | Not measured |
| PineTS | No 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.
“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///Original script//https://www.tradingview.com/script/wYknDlLx-super-Z///@version=4strategy("Super Z strategy - Thanks to Rafael Zioni", shorttitle="Super Z strategy",overlay=true,precision=6, initial_capital=10000,calc_on_every_tick=true, pyramiding=10, default_qty_type=strategy.fixed, default_qty_value=10000, currency=currency.EUR)src5 = input(close) tf = input(1440)len5 = timeframe.isintraday and timeframe.multiplier >= 1 ? tf / timeframe.multiplier * 7 : timeframe.isintraday and timeframe.multiplier < 60 ? 60 / timeframe.multiplier * 24 * 7 : 7ma = ema(src5*volume, len5) / ema(volume, len5)//script taken from https://www.tradingview.com/script/kChCRRZI-Hull-Moving-Average/src1 = map(src1, len5) => n = 0.0 s = 0.0 for i = 0 to len5 - 1 w = (len5 - i) * len5 n := n + w s := s + src5[i] * w s / nhm = 2.0 * p(src1, floor(len5 / 2)) - p(src1, len5)vhma = p(hm, floor(sqrt(len5)))lineColor = vhma > vhma[1] ? color.lime : color.redplot(vhma, title="VHMA", color=lineColor ,linewidth=3)hColor = true,vis = truehu = hColor ? (vhma > vhma[2] ? #00ff00 : #ff0000) : #ff9800vl = vhma[0]ll = vhma[1]m1 = plot(vl, color=hu, linewidth=1, transp=60)m2 = plot(vis ? ll : na, color=hu, linewidth=2, transp=80)fill(m1, m2, color=hu, transp=70)//b = timeframe.isintraday and timeframe.multiplier >= 1 ? 60 / timeframe.multiplier * 7 : timeframe.isintraday and timeframe.multiplier < 60 ? 60 / timeframe.multiplier * 24 * 7 : 7//res5 = input("D", type=input.resolution)o = security(syminfo.tickerid, res5, open, barmerge.gaps_off, barmerge.lookahead_on)c = security(syminfo.tickerid, res5, close, barmerge.gaps_off, barmerge.lookahead_on)hz = security(syminfo.tickerid, res5, high, barmerge.gaps_off, barmerge.lookahead_on)l = security(syminfo.tickerid, res5, low, barmerge.gaps_off, barmerge.lookahead_on)col = c >= o ? color.lime : color.redppo = plot(b ? o >= c ? hz : l : o, color=col, title="Open", style=plot.style_stepline, transp=100)ppc = plot(b ? o <= c ? hz : l : c, color=col, title="Close", style=plot.style_stepline, transp=100)plot(b and hz > c ? hz : na, color=col, title="High", style=plot.style_circles, linewidth=2,transp=60)plot(b and l < c ? l : na, color=col, title="Low", style=plot.style_circles,linewidth=2, transp=60)fill(ppo, ppc, col)//// INPUTS //st_mult = input(1, title = 'SuperTrend Multiplier', minval = 0, maxval = 100, step = 0.01)st_period = input(50, title = 'SuperTrend Period', minval = 1)// CALCULATIONS //up_lev =l - (st_mult * atr(st_period))dn_lev = hz + (st_mult * atr(st_period))up_trend = 0.0up_trend := c[1] > up_trend[1] ? max(up_lev, up_trend[1]) : up_levdown_trend = 0.0down_trend := c[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev// Calculate trend vartrend = 0trend := c > down_trend[1] ? 1: c < up_trend[1] ? -1 : nz(trend[1], 1)// Calculate SuperTrend Linest_line = trend ==1 ? up_trend : down_trend// Plotting//plot(st_line[1], color = trend == 1 ? color.green : color.red , style = plot.style_cross, linewidth = 2, title = "SuperTrend")buy=crossover( c, st_line)sell=crossunder(c, st_line)signal=input(false)/////////////// Plotting /////////////// plotshape(signal and buy, style=shape.triangleup, size=size.normal, location=location.belowbar, color=color.lime)plotshape(signal and sell, style=shape.triangledown, size=size.normal, location=location.abovebar, color=color.red)if (buy) strategy.entry("My Long Entry Id", strategy.long)if (sell) strategy.entry("My Short Entry Id", strategy.short)