https://www.tradingview.com/script/NIGCEUME-Super-Z-strategy-Thanks-to-Rafael-Zioni/ / 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=4 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) 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 : 7 ma = ema(src5*volume, len5) / ema(volume, len5) //script taken from https://www.tradingview.com/script/kChCRRZI-Hull-Moving-Average/ src1 = ma p(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 / n hm = 2.0 * p(src1, floor(len5 / 2)) - p(src1, len5) vhma = p(hm, floor(sqrt(len5))) lineColor = vhma > vhma[1] ? color.lime : color.red plot(vhma, title="VHMA", color=lineColor ,linewidth=3) hColor = true,vis = true hu = hColor ? (vhma > vhma[2] ? #00ff00 : #ff0000) : #ff9800 vl = 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.red ppo = 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.0 up_trend := c[1] > up_trend[1] ? max(up_lev, up_trend[1]) : up_lev down_trend = 0.0 down_trend := c[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev // Calculate trend var trend = 0 trend := c > down_trend[1] ? 1: c < up_trend[1] ? -1 : nz(trend[1], 1) // Calculate SuperTrend Line st_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)