Zeal Terminal Open in Zeal Terminal

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
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (6)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$-69,987,000$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. 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.
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

Verified

Same 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)⋯

Clean v5

VerifiedDownload the v5 script

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.

SettingDefaultType and rangeFeeds
Src5 (no label in the script)closesourcema s
Tf (no label in the script)1440intlen5
Res5 (no label in the script)Dtimeframe (written input.resolution)o c hz l
SuperTrend Multiplier1int · min 0 · max 100 · step 0.01up_lev dn_lev
SuperTrend Period50int · min 1up_lev dn_lev
Signal (no label in the script)falseboolplotshape

What it calculates

  • EMA (ema, ta.ema in v5)src5*volume, len5ma · line 13
  • ATR (atr, ta.atr in v5)SuperTrend Period (50)up_lev · line 57
  • ATR (atr, ta.atr in v5)SuperTrend Period (50)dn_lev · line 58
  • Crossover (crossover, ta.crossover in v5)c, st_linebuy · line 70
  • Crossunder (crossunder, ta.crossunder in 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.

volumevolumeprice dataclosecloseprice datahigh · low · closehigh · low · closeprice datast_multSuperTrend Multipliersetting · 1st_periodSuperTrend Periodsetting · 50tfTfsetting · 1440openopenprice datares5Res5setting · Dhighhighprice datalowlowprice datamaEMA→ maup_levATR→ up_levdn_levATR→ dn_levbuyCrossover→ buysellCrossunder→ selllen5len5valuesrc1src1valuennvaluessvaluewwvaluehmhmvaluevhmavhmavaluevl, llvl · ll2 valuesbbvalueoovalueccvaluehzhzvaluellvalueup_trendup_trendvaluedown_trenddown_trendvaluetrendtrendvaluest_linest_linevaluelineColor, hu, colColourlineColor · hu +1entry:My Long Entry IdOpen My Long Entry Idstrategy.entryentry:My Short Entry IdOpen My Short Entry Idstrategy.entryplot:27VHMAplotplot:32plotplotplot:33plotplotfill:34Fillfill × 2plot:47Openplotplot:48Closeplotplot:49Highplotplot:50Lowplotfill:51Fillfill × 2plotshape:74plotshapeplotshapeplotshape:75plotshapeplotshape

Order rules

OrderFires whenBy defaultLine
Open My Long Entry Id long(buy)On77
Open My Short Entry Id short(sell)On79

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.

15/15trades 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. On 0 of them the position changed while the bar was forming before it settled. Anyone watching live sees those changes; once the bar closes it matches history.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D−404,823.0%+102.5%5639%0.972,951,790.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+5,627,720.0%+5.5%1984%38.84141,290.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−245,494.0%+9.8%6231%0.77447,221.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+243,315.0%+8.4%1794%30.211,643.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−14,054.0%+16.7%6038%0.7510,237.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+11,086.0%+21.5%1989%70.29190.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+4,633.0%+148.3%5439%1.0334,630.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+56,917.0%+17.1%2171%11.185,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 barsTradesWonP&L
Rising market2232%−$429,832,000.00
Sideways market2454%$490,342,000.00
Falling market1020%−$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.

0%8,338,788%
All 56 trades
SideEntryExitBarsP&L
short20 Mar 2024 61,937.4026 Mar 2024 69,880.006−$79,425,900.00
long26 Mar 2024 69,880.003 Apr 2024 65,464.008−$44,160,100.00
short3 Apr 2024 65,464.009 Apr 2024 71,620.006−$61,560,100.00
long9 Apr 2024 71,620.0014 Apr 2024 63,924.505−$76,954,800.00
short14 Apr 2024 63,924.504 May 2024 62,882.0020$10,425,100.00
long4 May 2024 62,882.0012 Jun 2024 67,314.2039$44,322,200.00
short12 Jun 2024 67,314.2015 Jul 2024 60,797.9033$65,163,200.00
long15 Jul 2024 60,797.901 Aug 2024 64,628.0017$38,301,000.00
short1 Aug 2024 64,628.009 Aug 2024 61,686.008$29,420,100.00
long9 Aug 2024 61,686.0028 Aug 2024 59,415.0019−$22,710,000.00
short28 Aug 2024 59,415.0011 Sep 2024 57,636.0014$17,790,100.00
long11 Sep 2024 57,636.002 Oct 2024 60,804.9021$31,689,300.00
short2 Oct 2024 60,804.9015 Oct 2024 66,084.0013−$52,790,800.00
long15 Oct 2024 66,084.004 Nov 2024 68,776.0020$26,919,900.00
short4 Nov 2024 68,776.007 Nov 2024 75,572.003−$67,960,000.00
long7 Nov 2024 75,572.0026 Nov 2024 93,010.0019$174,380,000.00
short26 Nov 2024 93,010.005 Dec 2024 98,587.309−$55,773,100.00
long5 Dec 2024 98,587.3019 Dec 2024 100,204.0014$16,166,900.00
short19 Dec 2024 100,204.007 Jan 2025 102,236.0019−$20,315,900.00
long7 Jan 2025 102,236.0010 Jan 2025 92,552.503−$96,831,100.00
short10 Jan 2025 92,552.5016 Jan 2025 100,497.006−$79,448,600.00
long16 Jan 2025 100,497.003 Feb 2025 97,700.6018−$27,967,600.00
short3 Feb 2025 97,700.603 Mar 2025 94,270.0028$34,306,000.00
long3 Mar 2025 94,270.0010 Mar 2025 80,734.507−$135,355,000.00
short10 Mar 2025 80,734.5013 Apr 2025 85,276.9034−$45,424,300.00
long13 Apr 2025 85,276.9030 May 2025 105,590.0047$203,128,000.00
short30 May 2025 105,590.0010 Jun 2025 110,263.0011−$46,732,700.00
long10 Jun 2025 110,263.0018 Jun 2025 104,551.008−$57,118,500.00
short18 Jun 2025 104,551.0026 Jun 2025 107,341.008−$27,894,200.00
long26 Jun 2025 107,341.001 Aug 2025 115,764.0036$84,234,800.00
short1 Aug 2025 115,764.008 Aug 2025 117,472.007−$17,079,500.00
long8 Aug 2025 117,472.0020 Aug 2025 112,873.0012−$45,990,700.00
short20 Aug 2025 112,873.009 Sep 2025 112,065.0020$8,077,200.00
long9 Sep 2025 112,065.0023 Sep 2025 112,651.0014$5,857,600.00
short23 Sep 2025 112,651.0030 Sep 2025 114,312.007−$16,609,800.00
long30 Sep 2025 114,312.0011 Oct 2025 112,774.0011−$15,374,800.00
short11 Oct 2025 112,774.0025 Oct 2025 111,005.0014$17,695,900.00
long25 Oct 2025 111,005.0030 Oct 2025 110,021.005−$9,836,000.00
short30 Oct 2025 110,021.0027 Nov 2025 90,484.0028$195,373,000.00
long27 Nov 2025 90,484.002 Dec 2025 86,286.005−$41,980,000.00
short2 Dec 2025 86,286.005 Jan 2026 91,529.7034−$52,437,300.00
long5 Jan 2026 91,529.7021 Jan 2026 88,427.7016−$31,020,800.00
short21 Jan 2026 88,427.703 Mar 2026 68,830.1041$195,976,000.00
long3 Mar 2026 68,830.109 Mar 2026 65,971.206−$28,588,600.00
short9 Mar 2026 65,971.2016 Mar 2026 72,815.307−$68,440,500.00
long16 Mar 2026 72,815.3020 Mar 2026 69,930.004−$28,852,400.00
short20 Mar 2026 69,930.008 Apr 2026 71,924.2019−$19,942,100.00
long8 Apr 2026 71,924.2018 May 2026 77,457.7040$55,334,500.00
short18 May 2026 77,457.7014 Jun 2026 64,458.0027$129,997,000.00
long14 Jun 2026 64,458.0024 Jun 2026 62,734.6010−$17,234,400.00
short24 Jun 2026 62,734.605 Jul 2026 63,144.0011−$4,094,400.00
long5 Jul 2026 63,144.001 Aug 2026 62,887.9027−$2,561,300.00
short1 Aug 2026 62,887.9020 Aug 2026 69,334.8019−$64,469,000.00
long20 Aug 2026 69,334.8011 Sep 2026 76,568.7022$72,339,500.00
short11 Sep 2026 76,568.7019 Sep 2026 80,883.908−$43,151,300.00
long19 Sep 2026 80,883.909 Oct 2026 81,754.5020$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.

ScriptSharesTypeNetTradesMax drawdown
Super Z strategy - Thanks to Rafael Zioni this page—v4 strategy−404,823.0%562,951,790.0%
Trend Reversal - Potential pressure by BardiaB2atr emav4 strategy+133,960.0%51,504.8%
Simple Ema_ATR Strategy HulkTrading by TheHulkTradingema atrv4 strategy+2.2%1415.6%
Keltner Breakout Strategy by Zeal Terminalema atrv5 strategy+3.5%212.3%
[EKIN] ATR Exit Strategy by ekinbasarkomurema atrv5 strategy+781.7%302,960.8%
DEMA-EMA & VOLATILITY (VAMS) by Qorbanjfema atrv4 strategy+2,833,450.0%1915,721.0%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 18 msWith a workaround 1,000 bars in 99 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.

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