//@version=5 //By Mihkel00 // This script is designed for the NNFX Method, so it is recommended for Daily charts only. // Tried to implement a few VP NNFX Rules // This script has a SSL / Baseline (you can choose between the SSL or MA), a secondary SSL for continiuation trades and a third SSL for exit trades. // Alerts added for Baseline entries, SSL2 continuations, Exits. // Baseline has a Keltner Channel setting for "in zone" Gray Candles // Added "Candle Size > 1 ATR" Diamonds from my old script with the criteria of being within Baseline ATR range. // Credits // Strategy causecelebre https://www.tradingview.com/u/causecelebre/ // SSL Channel ErwinBeckers https://www.tradingview.com/u/ErwinBeckers/ // Moving Averages jiehonglim https://www.tradingview.com/u/jiehonglim/ // Moving Averages everget https://www.tradingview.com/u/everget/ // "Many Moving Averages" script Fractured https://www.tradingview.com/u/Fractured/ indicator('SSL Hybrid', overlay=true) show_Baseline = input(title='Show Baseline', defval=true) show_SSL1 = input(title='Show SSL1', defval=false) show_atr = input(title='Show ATR bands', defval=true) //ATR atrlen = input(14, 'ATR Period') mult = input.float(1, 'ATR Multi', step=0.1) smoothing = input.string(title='ATR Smoothing', defval='WMA', options=['RMA', 'SMA', 'EMA', 'WMA']) ma_function(source, atrlen) => if smoothing == 'RMA' ta.rma(source, atrlen) else if smoothing == 'SMA' ta.sma(source, atrlen) else if smoothing == 'EMA' ta.ema(source, atrlen) else ta.wma(source, atrlen) atr_slen = ma_function(ta.tr(true), atrlen) ////ATR Up/Low Bands upper_band = atr_slen * mult + close lower_band = close - atr_slen * mult ////BASELINE / SSL1 / SSL2 / EXIT MOVING AVERAGE VALUES maType = input.string(title='SSL1 / Baseline Type', defval='HMA', options=['SMA', 'EMA', 'DEMA', 'TEMA', 'LSMA', 'WMA', 'MF', 'VAMA', 'TMA', 'HMA', 'JMA', 'Kijun v2', 'EDSMA', 'McGinley']) len = input(title='SSL1 / Baseline Length', defval=60) SSL2Type = input.string(title='SSL2 / Continuation Type', defval='JMA', options=['SMA', 'EMA', 'DEMA', 'TEMA', 'WMA', 'MF', 'VAMA', 'TMA', 'HMA', 'JMA', 'McGinley']) len2 = input(title='SSL 2 Length', defval=5) // SSL3Type = input.string(title='EXIT Type', defval='HMA', options=['DEMA', 'TEMA', 'LSMA', 'VAMA', 'TMA', 'HMA', 'JMA', 'Kijun v2', 'McGinley', 'MF']) len3 = input(title='EXIT Length', defval=15) src = input(title='Source', defval=close) // tema(src, len) => ema1 = ta.ema(src, len) ema2 = ta.ema(ema1, len) ema3 = ta.ema(ema2, len) 3 * ema1 - 3 * ema2 + ema3 kidiv = input.int(defval=1, maxval=4, title='Kijun MOD Divider') jurik_phase = input(title='* Jurik (JMA) Only - Phase', defval=3) jurik_power = input(title='* Jurik (JMA) Only - Power', defval=1) volatility_lookback = input(10, title='* Volatility Adjusted (VAMA) Only - Volatility lookback length') //MF beta = input.float(0.8, minval=0, maxval=1, step=0.1, title='Modular Filter, General Filter Only - Beta') feedback = input(false, title='Modular Filter Only - Feedback') z = input.float(0.5, title='Modular Filter Only - Feedback Weighting', step=0.1, minval=0, maxval=1) //EDSMA ssfLength = input.int(title='EDSMA - Super Smoother Filter Length', minval=1, defval=20) ssfPoles = input.int(title='EDSMA - Super Smoother Filter Poles', defval=2, options=[2, 3]) //---- //EDSMA get2PoleSSF(src, length) => PI = 2 * math.asin(1) arg = math.sqrt(2) * PI / length a1 = math.exp(-arg) b1 = 2 * a1 * math.cos(arg) c2 = b1 c3 = -math.pow(a1, 2) c1 = 1 - c2 - c3 ssf = 0.0 ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2]) ssf get3PoleSSF(src, length) => PI = 2 * math.asin(1) arg = PI / length a1 = math.exp(-arg) b1 = 2 * a1 * math.cos(1.738 * arg) c1 = math.pow(a1, 2) coef2 = b1 + c1 coef3 = -(c1 + b1 * c1) coef4 = math.pow(c1, 2) coef1 = 1 - coef2 - coef3 - coef4 ssf = 0.0 ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3]) ssf ma(type, src, len) => float result = 0 if type == 'TMA' result := ta.sma(ta.sma(src, math.ceil(len / 2)), math.floor(len / 2) + 1) result if type == 'MF' ts = 0. b = 0. c = 0. os = 0. //---- alpha = 2 / (len + 1) a = feedback ? z * src + (1 - z) * nz(ts[1], src) : src //---- b := a > alpha * a + (1 - alpha) * nz(b[1], a) ? a : alpha * a + (1 - alpha) * nz(b[1], a) c := a < alpha * a + (1 - alpha) * nz(c[1], a) ? a : alpha * a + (1 - alpha) * nz(c[1], a) os := a == b ? 1 : a == c ? 0 : os[1] //---- upper = beta * b + (1 - beta) * c lower = beta * c + (1 - beta) * b ts := os * upper + (1 - os) * lower result := ts result if type == 'LSMA' result := ta.linreg(src, len, 0) result if type == 'SMA' // Simple result := ta.sma(src, len) result if type == 'EMA' // Exponential result := ta.ema(src, len) result if type == 'DEMA' // Double Exponential e = ta.ema(src, len) result := 2 * e - ta.ema(e, len) result if type == 'TEMA' // Triple Exponential e = ta.ema(src, len) result := 3 * (e - ta.ema(e, len)) + ta.ema(ta.ema(e, len), len) result if type == 'WMA' // Weighted result := ta.wma(src, len) result if type == 'VAMA' // Volatility Adjusted /// Copyright © 2019 to present, Joris Duyck (JD) mid = ta.ema(src, len) dev = src - mid vol_up = ta.highest(dev, volatility_lookback) vol_down = ta.lowest(dev, volatility_lookback) result := mid + math.avg(vol_up, vol_down) result if type == 'HMA' // Hull result := ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len))) result if type == 'JMA' // Jurik /// Copyright © 2018 Alex Orekhov (everget) /// Copyright © 2017 Jurik Research and Consulting. phaseRatio = jurik_phase < -100 ? 0.5 : jurik_phase > 100 ? 2.5 : jurik_phase / 100 + 1.5 beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2) alpha = math.pow(beta, jurik_power) jma = 0.0 e0 = 0.0 e0 := (1 - alpha) * src + alpha * nz(e0[1]) e1 = 0.0 e1 := (src - e0) * (1 - beta) + beta * nz(e1[1]) e2 = 0.0 e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1]) jma := e2 + nz(jma[1]) result := jma result if type == 'Kijun v2' kijun = math.avg(ta.lowest(len), ta.highest(len)) //, (open + close)/2) conversionLine = math.avg(ta.lowest(len / kidiv), ta.highest(len / kidiv)) delta = (kijun + conversionLine) / 2 result := delta result if type == 'McGinley' mg = 0.0 mg := na(mg[1]) ? ta.ema(src, len) : mg[1] + (src - mg[1]) / (len * math.pow(src / mg[1], 4)) result := mg result if type == 'EDSMA' zeros = src - nz(src[2]) avgZeros = (zeros + zeros[1]) / 2 // Ehlers Super Smoother Filter ssf = ssfPoles == 2 ? get2PoleSSF(avgZeros, ssfLength) : get3PoleSSF(avgZeros, ssfLength) // Rescale filter in terms of Standard Deviations stdev = ta.stdev(ssf, len) scaledFilter = stdev != 0 ? ssf / stdev : 0 alpha = 5 * math.abs(scaledFilter) / len edsma = 0.0 edsma := alpha * src + (1 - alpha) * nz(edsma[1]) result := edsma result result ///SSL 1 and SSL2 emaHigh = ma(maType, high, len) emaLow = ma(maType, low, len) maHigh = ma(SSL2Type, high, len2) maLow = ma(SSL2Type, low, len2) ///EXIT ExitHigh = ma(SSL3Type, high, len3) ExitLow = ma(SSL3Type, low, len3) ///Keltner Baseline Channel BBMC = ma(maType, close, len) useTrueRange = input(true) multy = input.float(0.2, step=0.05, title='Base Channel Multiplier') Keltma = ma(maType, src, len) range_1 = useTrueRange ? ta.tr : high - low rangema = ta.ema(range_1, len) upperk = Keltma + rangema * multy lowerk = Keltma - rangema * multy //Baseline Violation Candle open_pos = open * 1 close_pos = close * 1 difference = math.abs(close_pos - open_pos) atr_violation = difference > atr_slen InRange = upper_band > BBMC and lower_band < BBMC candlesize_violation = atr_violation and InRange plotshape(candlesize_violation, color=color.new(color.white, 0), size=size.tiny, style=shape.diamond, location=location.top, title='Candle Size > 1xATR') //SSL1 VALUES Hlv = int(na) Hlv := close > emaHigh ? 1 : close < emaLow ? -1 : Hlv[1] sslDown = Hlv < 0 ? emaHigh : emaLow //SSL2 VALUES Hlv2 = int(na) Hlv2 := close > maHigh ? 1 : close < maLow ? -1 : Hlv2[1] sslDown2 = Hlv2 < 0 ? maHigh : maLow //EXIT VALUES Hlv3 = int(na) Hlv3 := close > ExitHigh ? 1 : close < ExitLow ? -1 : Hlv3[1] sslExit = Hlv3 < 0 ? ExitHigh : ExitLow base_cross_Long = ta.crossover(close, sslExit) base_cross_Short = ta.crossover(sslExit, close) codiff = base_cross_Long ? 1 : base_cross_Short ? -1 : na //COLORS show_color_bar = input(title='Color Bars', defval=true) color_bar = close > upperk ? #00c3ff : close < lowerk ? #ff0062 : color.gray color_ssl1 = close > sslDown ? #00c3ff : close < sslDown ? #ff0062 : na //PLOTS plotarrow(codiff, colorup=color.new(#00c3ff, 20), colordown=color.new(#ff0062, 20), title='Exit Arrows', maxheight=20, offset=0) p1 = plot(show_Baseline ? BBMC : na, color=color_bar, linewidth=4, title='MA Baseline', transp=0) DownPlot = plot(show_SSL1 ? sslDown : na, title='SSL1', linewidth=3, color=color_ssl1, transp=10) barcolor(show_color_bar ? color_bar : na) up_channel = plot(show_Baseline ? upperk : na, color=color_bar, title='Baseline Upper Channel') low_channel = plot(show_Baseline ? lowerk : na, color=color_bar, title='Basiline Lower Channel') fill(up_channel, low_channel, color=color_bar, transp=90) ////SSL2 Continiuation from ATR atr_crit = input.float(0.9, step=0.1, title='Continuation ATR Criteria') upper_half = atr_slen * atr_crit + close lower_half = close - atr_slen * atr_crit buy_inatr = lower_half < sslDown2 sell_inatr = upper_half > sslDown2 sell_cont = close < BBMC and close < sslDown2 buy_cont = close > BBMC and close > sslDown2 sell_atr = sell_inatr and sell_cont buy_atr = buy_inatr and buy_cont atr_fill = buy_atr ? color.green : sell_atr ? color.purple : color.white LongPlot = plot(sslDown2, title='SSL2', linewidth=2, color=atr_fill, style=plot.style_circles, transp=0) u = plot(show_atr ? upper_band : na, '+ATR', color=color.new(color.white, 80)) l = plot(show_atr ? lower_band : na, '-ATR', color=color.new(color.white, 80)) //ALERTS alertcondition(ta.crossover(close, sslDown), title='SSL Cross Alert', message='SSL1 has crossed.') alertcondition(ta.crossover(close, sslDown2), title='SSL2 Cross Alert', message='SSL2 has crossed.') alertcondition(sell_atr, title='Sell Continuation', message='Sell Continuation.') alertcondition(buy_atr, title='Buy Continuation', message='Buy Continuation.') alertcondition(ta.crossover(close, sslExit), title='Exit Sell', message='Exit Sell Alert.') alertcondition(ta.crossover(sslExit, close), title='Exit Buy', message='Exit Buy Alert.') alertcondition(ta.crossover(close, upperk), title='Baseline Buy Entry', message='Base Buy Alert.') alertcondition(ta.crossover(lowerk, close), title='Baseline Sell Entry', message='Base Sell Alert.') /////////////////////// Screener Section //////////////////////////// var tableTheme = "========= Table Theme =========" bgColor = input.color(#d1d4dc, "Background", group = tableTheme, inline = "table") frameColor = input.color(color.white, "Frame", group = tableTheme, inline = "table") textColor = input.color(color.rgb(0, 0, 0), "Text", group = tableTheme, inline = "table") textSize = switch input.string("Auto", "Size", options = ['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group = tableTheme) "Auto" => size.auto "Tiny" => size.tiny "Small" => size.small "Normal" => size.normal "Large" => size.large "Huge" => size.huge location = switch input.string("Top Right", "Table Location", options = ['Top Right', 'Top Center', 'Top Left', 'Middle Right', 'Middle Center', 'Middle Left', 'Bottom Right', 'Bottom Center', 'Bottom Left'], group = tableTheme) "Top Right" => position.top_right "Top Center" => position.top_center "Top Left" => position.top_left "Middle Right" => position.middle_right "Middle Center" => position.middle_center "Middle Left" => position.middle_left "Bottom Right" => position.bottom_right "Bottom Center" => position.bottom_center "Bottom Left" => position.bottom_left /////////////////// Screener //////////////////////// getSignal(symbol, longArray, shortArray)=> [long, short] = request.security(symbol, "", [buy, sell]) if long longArray.push(symbol) if short shortArray.push(symbol) gticker = '=============== Watchlist ===============' symbol1 = input.symbol(defval = "BINANCE:BTCUSDT", title="symbol1", group=gticker) symbol2 = input.symbol(defval = "BINANCE:ETHUSDT", title="symbol2", group=gticker) symbol4 = input.symbol(defval = "BINANCE:BNBUSDT", title="symbol4", group=gticker) symbol5 = input.symbol(defval = "BINANCE:SOLUSDT", title="symbol5", group=gticker) symbol6 = input.symbol(defval = "BINANCE:XRPUSDT", title="symbol6", group=gticker) symbol8 = input.symbol(defval = "BINANCE:ADAUSDT", title="symbol8", group=gticker) symbol9 = input.symbol(defval = "BINANCE:AVAXUSDT", title="symbol9", group=gticker) symbol10 = input.symbol(defval = "BINANCE:DOGEUSDT", title="symbol10", group=gticker) symbol12 = input.symbol(defval = "BINANCE:TRXUSDT", title="symbol12", group=gticker) symbol13 = input.symbol(defval = "BINANCE:DOTUSDT", title="symbol13", group=gticker) symbol17 = input.symbol(defval = "BINANCE:SHIBUSDT", title="symbol17", group=gticker) symbol19 = input.symbol(defval = "BINANCE:BCHUSDT", title="symbol19", group=gticker) symbol20 = input.symbol(defval = "BINANCE:LTCUSDT", title="symbol20", group=gticker) symbol21 = input.symbol(defval = "BINANCE:UNIUSDT", title="symbol21", group=gticker) symbol22 = input.symbol(defval = "BINANCE:IMXUSDT", title="symbol22", group=gticker) symbol23 = input.symbol(defval = "BINANCE:ATOMUSDT", title="symbol23", group=gticker) symbol24 = input.symbol(defval = "BINANCE:ETCUSDT", title="symbol24", group=gticker) symbol26 = input.symbol(defval = "BINANCE:APTUSDT", title="symbol26", group=gticker) symbol27 = input.symbol(defval = "BINANCE:VETUSDT", title="symbol27", group=gticker) symbol28 = input.symbol(defval = "BINANCE:STXUSDT", title="symbol28", group=gticker) symbol29 = input.symbol(defval = "BINANCE:OPUSDT", title="symbol29", group=gticker) symbol30 = input.symbol(defval = "BINANCE:NEARUSDT", title="symbol30", group=gticker) symbol31 = input.symbol(defval = "BINANCE:XLMUSDT", title="symbol31", group=gticker) symbol32 = input.symbol(defval = "BINANCE:INJUSDT", title="symbol32", group=gticker) symbol35 = input.symbol(defval = "BINANCE:FILUSDT", title="symbol35", group=gticker) symbol37 = input.symbol(defval = "BINANCE:LDOUSDT", title="symbol37", group=gticker) symbol39 = input.symbol(defval = "BINANCE:HBARUSDT", title="symbol39", group=gticker) symbol40 = input.symbol(defval = "BINANCE:ARBUSDT", title="symbol40", group=gticker) symbol41 = input.symbol(defval = "BINANCE:SEIUSDT", title="symbol41", group=gticker) symbol53 = input.symbol(defval = "BINANCE:ALGOUSDT", title="symbol53", group=gticker) longArray = array.new_string(na) shortArray = array.new_string(na) getSignal(symbol1,longArray, shortArray) getSignal(symbol2,longArray, shortArray) getSignal(symbol4,longArray, shortArray) getSignal(symbol5,longArray, shortArray) getSignal(symbol6,longArray, shortArray) getSignal(symbol8,longArray, shortArray) getSignal(symbol9,longArray, shortArray) getSignal(symbol10,longArray, shortArray) getSignal(symbol12,longArray, shortArray) getSignal(symbol13,longArray, shortArray) getSignal(symbol17,longArray, shortArray) getSignal(symbol19,longArray, shortArray) getSignal(symbol20,longArray, shortArray) getSignal(symbol21,longArray, shortArray) getSignal(symbol22,longArray, shortArray) getSignal(symbol23,longArray, shortArray) getSignal(symbol24,longArray, shortArray) getSignal(symbol26,longArray, shortArray) getSignal(symbol27,longArray, shortArray) getSignal(symbol28,longArray, shortArray) getSignal(symbol29,longArray, shortArray) getSignal(symbol30,longArray, shortArray) getSignal(symbol31,longArray, shortArray) getSignal(symbol32,longArray, shortArray) getSignal(symbol35,longArray, shortArray) getSignal(symbol37,longArray, shortArray) getSignal(symbol39,longArray, shortArray) getSignal(symbol40,longArray, shortArray) getSignal(symbol41,longArray, shortArray) getSignal(symbol53,longArray, shortArray) getSym(sym)=> str.tostring(array.get(str.split(sym, ":"), 1)) if barstate.islast rowSize = math.max(longArray.size(), shortArray.size()) dashboard = table.new(location, 2, rowSize + 3, border_color = frameColor, border_width = 1) dashboard.cell(0, 0, text = "Screener", bgcolor = bgColor, text_size = textSize, text_color = textColor) dashboard.merge_cells(0, 0, 1, 0) dashboard.cell(0, 1, text = "Long Signal", bgcolor = color.lime, text_size = textSize, text_color = color.black) dashboard.cell(1, 1, text = "Short Signal", bgcolor = color.red, text_size = textSize, text_color = color.white) if longArray.size() > 0 for i = 0 to longArray.size() - 1 dashboard.cell(0, i + 2, getSym(longArray.get(i)), text_color = textColor, bgcolor = color.lime, text_size = textSize) else dashboard.cell(0, 2, text = "No Signal", bgcolor = color.yellow, text_size = textSize, text_color = color.black) if shortArray.size() > 0 for i = 0 to shortArray.size() - 1 dashboard.cell(1, i + 2, getSym(shortArray.get(i)), text_color = textColor, bgcolor = color.red, text_size = textSize) else dashboard.cell(1, 2, text = "No Signal", bgcolor = color.yellow, text_size = textSize, text_color = color.black) // Inputs //a = input(1, title='Key Vaule. \'This changes the sensitivity\'') //c = input(10, title='ATR Period') //h = input(false, title='Signals from Heikin Ashi Candles') //xATR = ta.atr(c) //nLoss = a * xATR //src = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead=barmerge.lookahead_off) : close //xATRTrailingStop = 0.0 //iff_1 = src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss //iff_2 = src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : iff_1 xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : iff_2 //pos = 0 //iff_3 = src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0) pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : iff_3 //xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue //ema = ta.ema(src, 1) //above = ta.crossover(ema, xATRTrailingStop) //below = ta.crossover(xATRTrailingStop, ema) //buy = src > xATRTrailingStop and above //sell = src < xATRTrailingStop and below //barbuy = src > xATRTrailingStop //barsell = src < xATRTrailingStop plotshape(buy, title='Buy', text='Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny) plotshape(sell, title='Sell', text='Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny) barcolor(barbuy ? color.green : na) barcolor(barsell ? color.red : na) alertcondition(buy, 'UT Long', 'UT Long') alertcondition(sell, 'UT Short', 'UT Short')