//@version=5 indicator("Fiver", overlay = true) // VMC { // PARAMETERS { // WaveTrend wtChannelLen = input(9, title='WT Channel Length', group = "VMC Settings") wtAverageLen = input(12, title='WT Average Length') wtMASource = input(hlc3, title='WT MA Source') wtMALen = input(3, title='WT MA Length') // WaveTrend Overbought & Oversold lines obLevel = input(53, title='WT Overbought Level 1') obLevel2 = input(60, title='WT Overbought Level 2') obLevel3 = input(100, title='WT Overbought Level 3') osLevel = input(-53, title='WT Oversold Level 1') osLevel2 = input(-60, title='WT Oversold Level 2') osLevel3 = input(-75, title='WT Oversold Level 3') // Divergence WT showHiddenDiv_nl = input(true, title='Not apply OB/OS Limits on Hidden Divergences') wtDivOBLevel = input(45, title='WT Bearish Divergence min') wtDivOSLevel = input(-65, title='WT Bullish Divergence min') // Divergence extra range wtDivOBLevel_add = input(15, title='WT 2nd Bearish Divergence') wtDivOSLevel_add = input(-40, title='WT 2nd Bullish Divergence 15 min') // RSI+MFI rsiMFIperiod = input(60, title='MFI Period') rsiMFIMultiplier = input.float(150, title='MFI Area multiplier') rsiMFIPosY = input(2.5, title='MFI Area Y Pos') // RSI rsiSRC = input(close, title='RSI Source') rsiLen = input(14, title='RSI Length') rsiOversold = input.int(30, title='RSI Oversold', minval=30, maxval=100) rsiOverbought = input.int(60, title='RSI Overbought', minval=0, maxval=60) // Divergence RSI rsiDivOBLevel = input(60, title='RSI Bearish Divergence min') rsiDivOSLevel = input(30, title='RSI Bullish Divergence min') // RSI Stochastic stochUseLog = input(true, title=' Use Log?') stochAvg = input(false, title='Use Average of both K & D') stochSRC = input(close, title='Stochastic RSI Source') stochLen = input(14, title='Stochastic RSI Length') stochRsiLen = input(14, title='RSI Length ') stochKSmooth = input(3, title='Stochastic RSI K Smooth') stochDSmooth = input(3, title='Stochastic RSI D Smooth') // Schaff Trend Cycle tcSRC = input(close, title='Schaff TC Source') tclength = input(10, title='Schaff TC') tcfastLength = input(23, title='Schaff TC Fast Lenght') tcslowLength = input(50, title='Schaff TC Slow Length') tcfactor = input(0.5, title='Schaff TC Factor') // Sommi Flag sommiVwapTF = input('720', title='Sommi F. Wave timeframe') sommiVwapBearLevel = input(0, title='F. Wave Bear Level (less than)') sommiVwapBullLevel = input(0, title='F. Wave Bull Level (more than)') soomiFlagWTBearLevel = input(0, title='WT Bear Level (more than)') soomiFlagWTBullLevel = input(0, title='WT Bull Level (less than)') soomiRSIMFIBearLevel = input(0, title='Money flow Bear Level (less than)') soomiRSIMFIBullLevel = input(0, title='Money flow Bull Level (more than)') // Sommi Diamond sommiHTCRes = input('60', title='HTF Candle Res. 1') sommiHTCRes2 = input('240', title='HTF Candle Res. 2') soomiDiamondWTBearLevel = input(0, title='WT Bear Level (More than)') soomiDiamondWTBullLevel = input(0, title='WT Bull Level (Less than)') // macd Colors macdWTColorsTF = input('240', title='MACD Colors MACD TF') darkMode = false // Colors colorRed = #ff0000 colorPurple = #e600e6 colorGreen = #3fff00 colorOrange = #e2a400 colorYellow = #ffe500 colorWhite = #ffffff colorPink = #ff00f0 colorBluelight = #31c0ff colorWT1 = #90caf9 colorWT2 = #0d47a1 colorWT2_ = #131722 colormacdWT1a = #4caf58 colormacdWT1b = #af4c4c colormacdWT1c = #7ee57e colormacdWT1d = #ff3535 colormacdWT2a = #305630 colormacdWT2b = #310101 colormacdWT2c = #132213 colormacdWT2d = #770000 // } PARAMETERS // FUNCTIONS { // Divergences f_top_fractal(src) => src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and src[2] > src[0] f_bot_fractal(src) => src[4] > src[2] and src[3] > src[2] and src[2] < src[1] and src[2] < src[0] f_fractalize(src) => f_top_fractal(src) ? 1 : f_bot_fractal(src) ? -1 : 0 f_findDivs(src, topLimit, botLimit, useLimits) => fractalTop = f_fractalize(src) > 0 and (useLimits ? src[2] >= topLimit : true) ? src[2] : na fractalBot = f_fractalize(src) < 0 and (useLimits ? src[2] <= botLimit : true) ? src[2] : na highPrev = ta.valuewhen(fractalTop, src[2], 0)[2] highPrice = ta.valuewhen(fractalTop, high[2], 0)[2] lowPrev = ta.valuewhen(fractalBot, src[2], 0)[2] lowPrice = ta.valuewhen(fractalBot, low[2], 0)[2] bearSignal = fractalTop and high[2] > highPrice and src[2] < highPrev bullSignal = fractalBot and low[2] < lowPrice and src[2] > lowPrev bearDivHidden = fractalTop and high[2] < highPrice and src[2] > highPrev bullDivHidden = fractalBot and low[2] > lowPrice and src[2] < lowPrev [fractalTop, fractalBot, lowPrev, bearSignal, bullSignal, bearDivHidden, bullDivHidden] // RSI+MFI f_rsimfi(_period, _multiplier, _tf) => request.security(syminfo.tickerid, _tf, ta.sma((close - open) / (high - low) * _multiplier, _period) - rsiMFIPosY) // WaveTrend f_wavetrend(src, chlen, avg, malen, tf) => tfsrc = request.security(syminfo.tickerid, tf, src) esa = ta.ema(tfsrc, chlen) de = ta.ema(math.abs(tfsrc - esa), chlen) ci = (tfsrc - esa) / (0.015 * de) wt1 = request.security(syminfo.tickerid, tf, ta.ema(ci, avg)) wt2 = request.security(syminfo.tickerid, tf, ta.sma(wt1, malen)) wtVwap = wt1 - wt2 wtOversold = wt2 <= osLevel wtOverbought = wt2 >= obLevel wtCross = ta.cross(wt1, wt2) wtCrossUp = wt2 - wt1 <= 0 wtCrossDown = wt2 - wt1 >= 0 wtCrosslast = ta.cross(wt1[2], wt2[2]) wtCrossUplast = wt2[2] - wt1[2] <= 0 wtCrossDownlast = wt2[2] - wt1[2] >= 0 [wt1, wt2, wtOversold, wtOverbought, wtCross, wtCrossUp, wtCrossDown, wtCrosslast, wtCrossUplast, wtCrossDownlast, wtVwap] // Schaff Trend Cycle f_tc(src, length, fastLength, slowLength) => ema1 = ta.ema(src, fastLength) ema2 = ta.ema(src, slowLength) macdVal = ema1 - ema2 alpha = ta.lowest(macdVal, length) beta = ta.highest(macdVal, length) - alpha gamma = (macdVal - alpha) / beta * 100 gamma := beta > 0 ? gamma : nz(gamma[1]) delta = gamma delta := na(delta[1]) ? delta : delta[1] + tcfactor * (gamma - delta[1]) epsilon = ta.lowest(delta, length) zeta = ta.highest(delta, length) - epsilon eta = (delta - epsilon) / zeta * 100 eta := zeta > 0 ? eta : nz(eta[1]) stcReturn = eta stcReturn := na(stcReturn[1]) ? stcReturn : stcReturn[1] + tcfactor * (eta - stcReturn[1]) stcReturn // Stochastic RSI f_stochrsi(_src, _stochlen, _rsilen, _smoothk, _smoothd, _log, _avg) => src = _log ? math.log(_src) : _src rsi = ta.rsi(src, _rsilen) kk = ta.sma(ta.stoch(rsi, rsi, rsi, _stochlen), _smoothk) d1 = ta.sma(kk, _smoothd) avg_1 = math.avg(kk, d1) k = _avg ? avg_1 : kk [k, d1] // MACD f_macd(src, fastlen, slowlen, sigsmooth, tf) => fast_ma = request.security(syminfo.tickerid, tf, ta.ema(src, fastlen)) slow_ma = request.security(syminfo.tickerid, tf, ta.ema(src, slowlen)) macd = fast_ma - slow_ma signal = request.security(syminfo.tickerid, tf, ta.sma(macd, sigsmooth)) hist = macd - signal [macd, signal, hist] // MACD Colors on WT f_macdWTColors(tf) => hrsimfi = f_rsimfi(rsiMFIperiod, rsiMFIMultiplier, tf) [macd, signal, hist] = f_macd(close, 28, 42, 9, macdWTColorsTF) macdup = macd >= signal macddown = macd <= signal macdWT1Color = macdup ? hrsimfi > 0 ? colormacdWT1c : colormacdWT1a : macddown ? hrsimfi < 0 ? colormacdWT1d : colormacdWT1b : na macdWT2Color = macdup ? hrsimfi < 0 ? colormacdWT2c : colormacdWT2a : macddown ? hrsimfi < 0 ? colormacdWT2d : colormacdWT2b : na [macdWT1Color, macdWT2Color] // Get higher timeframe candle f_getTFCandle(_tf) => _open = request.security(ticker.heikinashi(syminfo.tickerid), _tf, open, barmerge.gaps_off, barmerge.lookahead_on) _close = request.security(ticker.heikinashi(syminfo.tickerid), _tf, close, barmerge.gaps_off, barmerge.lookahead_on) _high = request.security(ticker.heikinashi(syminfo.tickerid), _tf, high, barmerge.gaps_off, barmerge.lookahead_on) _low = request.security(ticker.heikinashi(syminfo.tickerid), _tf, low, barmerge.gaps_off, barmerge.lookahead_on) hl2 = (_high + _low) / 2.0 newBar = ta.change(_open) candleBodyDir = _close > _open [candleBodyDir, newBar] // Sommi flag f_findSommiFlag(tf, wt1, wt2, rsimfi, wtCross, wtCrossUp, wtCrossDown) => [hwt1, hwt2, hwtOversold, hwtOverbought, hwtCross, hwtCrossUp, hwtCrossDown, hwtCrosslast, hwtCrossUplast, hwtCrossDownlast, hwtVwap] = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, tf) bearPattern = rsimfi < soomiRSIMFIBearLevel and wt2 > soomiFlagWTBearLevel and wtCross and wtCrossDown and hwtVwap < sommiVwapBearLevel bullPattern = rsimfi > soomiRSIMFIBullLevel and wt2 < soomiFlagWTBullLevel and wtCross and wtCrossUp and hwtVwap > sommiVwapBullLevel [bearPattern, bullPattern, hwtVwap] f_findSommiDiamond(tf, tf2, wt1, wt2, wtCross, wtCrossUp, wtCrossDown) => [candleBodyDir, newBar] = f_getTFCandle(tf) [candleBodyDir2, newBar2] = f_getTFCandle(tf2) bearPattern = wt2 >= soomiDiamondWTBearLevel and wtCross and wtCrossDown and not candleBodyDir and not candleBodyDir2 bullPattern = wt2 <= soomiDiamondWTBullLevel and wtCross and wtCrossUp and candleBodyDir and candleBodyDir2 [bearPattern, bullPattern] // } FUNCTIONS // CALCULATE INDICATORS { // RSI rsi = ta.rsi(rsiSRC, rsiLen) rsiColor = rsi <= rsiOversold ? colorGreen : rsi >= rsiOverbought ? colorRed : colorPurple // RSI + MFI Area rsiMFI = f_rsimfi(rsiMFIperiod, rsiMFIMultiplier, timeframe.period) rsiMFIColor = rsiMFI > 0 ? #3ee145 : #ff3d2e // Calculates WaveTrend [wt1, wt2, wtOversold, wtOverbought, wtCross, wtCrossUp, wtCrossDown, wtCross_last, wtCrossUp_last, wtCrossDown_last, wtVwap] = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, timeframe.period) // Stochastic RSI [stochK, stochD] = f_stochrsi(stochSRC, stochLen, stochRsiLen, stochKSmooth, stochDSmooth, stochUseLog, stochAvg) // Schaff Trend Cycle tcVal = f_tc(tcSRC, tclength, tcfastLength, tcslowLength) // Sommi flag [sommiBearish, sommiBullish, hvwap] = f_findSommiFlag(sommiVwapTF, wt1, wt2, rsiMFI, wtCross, wtCrossUp, wtCrossDown) //Sommi diamond [sommiBearishDiamond, sommiBullishDiamond] = f_findSommiDiamond(sommiHTCRes, sommiHTCRes2, wt1, wt2, wtCross, wtCrossUp, wtCrossDown) // macd colors [macdWT1Color, macdWT2Color] = f_macdWTColors(macdWTColorsTF) // WT Divergences [wtFractalTop, wtFractalBot, wtLow_prev, wtBearDiv, wtBullDiv, wtBearDivHidden, wtBullDivHidden] = f_findDivs(wt2, wtDivOBLevel, wtDivOSLevel, true) [wtFractalTop_add, wtFractalBot_add, wtLow_prev_add, wtBearDiv_add, wtBullDiv_add, wtBearDivHidden_add, wtBullDivHidden_add] = f_findDivs(wt2, wtDivOBLevel_add, wtDivOSLevel_add, true) [wtFractalTop_nl, wtFractalBot_nl, wtLow_prev_nl, wtBearDiv_nl, wtBullDiv_nl, wtBearDivHidden_nl, wtBullDivHidden_nl] = f_findDivs(wt2, 0, 0, false) wtBearDivHidden_ = showHiddenDiv_nl ? wtBearDivHidden_nl : wtBearDivHidden wtBullDivHidden_ = showHiddenDiv_nl ? wtBullDivHidden_nl : wtBullDivHidden // RSI Divergences [rsiFractalTop, rsiFractalBot, rsiLow_prev, rsiBearDiv, rsiBullDiv, rsiBearDivHidden, rsiBullDivHidden] = f_findDivs(rsi, rsiDivOBLevel, rsiDivOSLevel, true) [rsiFractalTop_nl, rsiFractalBot_nl, rsiLow_prev_nl, rsiBearDiv_nl, rsiBullDiv_nl, rsiBearDivHidden_nl, rsiBullDivHidden_nl] = f_findDivs(rsi, 0, 0, false) rsiBearDivHidden_ = showHiddenDiv_nl ? rsiBearDivHidden_nl : rsiBearDivHidden rsiBullDivHidden_ = showHiddenDiv_nl ? rsiBullDivHidden_nl : rsiBullDivHidden // Stoch Divergences [stochFractalTop, stochFractalBot, stochLow_prev, stochBearDiv, stochBullDiv, stochBearDivHidden, stochBullDivHidden] = f_findDivs(stochK, 0, 0, false) // Small Circles WT Cross signalColor = wt2 - wt1 > 0 ? color.red : color.lime // Buy signal. buySignal = wtCross and wtCrossUp and wtOversold // Sell signal sellSignal = wtCross and wtCrossDown and wtOverbought sellSignalDiv_color = wtBearDiv ? colorRed : wtBearDiv_add ? color.new(colorRed, 60) : rsiBearDiv ? colorRed : na // Gold Buy lastRsi = ta.valuewhen(wtFractalBot, rsi[2], 0)[2] wtGoldBuy = (wtBullDiv or rsiBullDiv) and wtLow_prev <= osLevel3 and wt2 > osLevel3 and wtLow_prev - wt2 <= -5 and lastRsi < 30 // } CALCULATE INDICATORS bool vmcBuy = buySignal bool vmcSell = sellSignal // } // RSX { //------------------------------------------------------------------- //---- Input Parameters length = input(title='RSX: Length', defval=14, group = "RSX Settings") src = input(title='RSX: Source', defval=hlc3, group = "RSX Settings") obLevel_1 = input(title='RSX: OB Level', defval=70, group = "RSX Settings") osLevel_1 = input(title='RSX: OS Level', defval=30, group = "RSX Settings") show_rsx = false highlightBreakouts_ema = false highlightBreakouts = true showdivs_lib = true if showdivs_lib == false showdivs_lib := true showdivs_lib else showdivs_lib := false showdivs_lib piv = true shrt = true xbars = input.int(90, 'RSX: Div lookback period (bars)? [Libertus Divs]', minval=1, group = "RSX Settings") showdivs = false showdiv_labels2 = true showchan = false //input(false, title="RSX Divergences: Draw Channel [Neobutane Divs]") showhidden = false showdivs2 = false showdiv_labels22 = true showchan2 = false //input(false, title="LSMA-D Divergences: Draw Channel [Neobutane Divs]") showhidden2 = false //---- M1/M2, Midline Trend indication/Zones show_m1 = true show_m2 = true m1Level = input(title='RSX: M1 Level', defval=85, group = "RSX Settings") //60 m2Level = input(title='RSX: M2 Level', defval=15, group = "RSX Settings") //40 showArrows = true showArrowsCenter = false showArrowsEnter = true showArrowsExit = true showArrowsrsx_lsmaD = true rsx_lsmaD_obLevel = input(title='RSX/LSMA-D cross: OB Level', defval=70, group = "RSX Settings") rsx_lsmaD_osLevel = input(title='RSX/LSMA-D cross : OS Level', defval=30, group = "RSX Settings") //---- LSMA-K and LSMA-D Components show_lsmaD = true length_lsmaA_lsma = input.int(minval=2, defval=20, title='LSMA-D: LSMA-A Length', group = "RSX Settings") length_lsmaB_lsma = input.int(minval=2, defval=40, title='LSMA-D: LSMA-B Length', group = "RSX Settings") length_lsmaC_lsma = input.int(minval=2, defval=80, title='LSMA-D: LSMA-C Length', group = "RSX Settings") length_lsmaD_lsma = input.int(minval=2, defval=10, title='LSMA-D: Length', group = "RSX Settings") offset_lsmaA = input(defval=0, title='LSMA-D: LSMA-A Offset', group = "RSX Settings") offset_lsmaB = input(defval=0, title='LSMA-D: LSMA-B Offset', group = "RSX Settings") offset_lsmaC = input(defval=0, title='LSMA-D: LSMA-C Offset', group = "RSX Settings") offset_lsmaD = input(defval=-2, title='LSMA-D: Offset', group = "RSX Settings") //------------------------------------------------------------------- //---- RSX Component (Everget, Jaggedsoft) //---- Note: Probably a solid idea to not touch this section. f8 = 100 * src f10 = nz(f8[1]) v8 = f8 - f10 f18 = 3 / (length + 2) f20 = 1 - f18 f28 = 0.0 f28 := f20 * nz(f28[1]) + f18 * v8 f30 = 0.0 f30 := f18 * f28 + f20 * nz(f30[1]) vC = f28 * 1.5 - f30 * 0.5 f38 = 0.0 f38 := f20 * nz(f38[1]) + f18 * vC f40 = 0.0 f40 := f18 * f38 + f20 * nz(f40[1]) v10 = f38 * 1.5 - f40 * 0.5 f48 = 0.0 f48 := f20 * nz(f48[1]) + f18 * v10 f50 = 0.0 f50 := f18 * f48 + f20 * nz(f50[1]) v14 = f48 * 1.5 - f50 * 0.5 f58 = 0.0 f58 := f20 * nz(f58[1]) + f18 * math.abs(v8) f60 = 0.0 f60 := f18 * f58 + f20 * nz(f60[1]) v18 = f58 * 1.5 - f60 * 0.5 f68 = 0.0 f68 := f20 * nz(f68[1]) + f18 * v18 f70 = 0.0 f70 := f18 * f68 + f20 * nz(f70[1]) v1C = f68 * 1.5 - f70 * 0.5 f78 = 0.0 f78 := f20 * nz(f78[1]) + f18 * v1C f80 = 0.0 f80 := f18 * f78 + f20 * nz(f80[1]) v20 = f78 * 1.5 - f80 * 0.5 f88_ = 0.0 f90_ = 0.0 f88 = 0.0 f90_ := nz(f90_[1]) == 0 ? 1 : nz(f88[1]) <= nz(f90_[1]) ? nz(f88[1]) + 1 : nz(f90_[1]) + 1 f88 := nz(f90_[1]) == 0 and length - 1 >= 5 ? length - 1 : 5 f0 = f88 >= f90_ and f8 != f10 ? 1 : 0 f90 = f88 == f90_ and f0 == 0 ? 0 : f90_ v4_ = f88 < f90 and v20 > 0 ? (v14 / v20 + 1) * 50 : 50 rsx = v4_ > 100 ? 100 : v4_ < 0 ? 0 : v4_ rsxColor = rsx > obLevel_1 ? #0ebb23 : rsx < osLevel_1 ? #ff0000 : color.white //#512DA8 lsmaA = ta.linreg(rsx, length_lsmaA_lsma, offset_lsmaA) lsmaB = ta.linreg(rsx, length_lsmaB_lsma, offset_lsmaB) lsmaC = ta.linreg(rsx, length_lsmaC_lsma, offset_lsmaC) lsmaD = ta.linreg((lsmaA + lsmaB + lsmaC) / 3, length_lsmaD_lsma, offset_lsmaD) //------------------------------------------------------------------- //---- Chassis transparent = color.new(color.white, 100) //---- M1/M2 Marker // Custom M1/M2 levels of 40/60 by default // Set to transparent to keep out of the way if not using/needed m1_color = show_m1 ? color.aqua : transparent m2_color = show_m2 ? color.orange : transparent //---- obFillColor = rsx > obLevel_1 and highlightBreakouts ? #008000 : transparent osFillColor = rsx < osLevel_1 and highlightBreakouts ? #FF0000 : transparent ////////////////// ema21 = ta.ema(close, 21) //fib ema55 = ta.ema(close, 55) //fib upEmaFillColor = ema21 > ema55 and highlightBreakouts_ema ? color.orange : transparent downEmaFillColor = ema21 < ema55 and highlightBreakouts_ema ? color.aqua : transparent //////////////// //------------------------------------------------------------------- //------------------------------------------------------------------- // MA of RSX show_sma = input(false, 'SMA of RSX') show_ema = input(false, 'EMA of RSX') len_sma = input.int(9, minval=1, title='SMA of RSX Length') len_ema = input.int(45, minval=1, title='EMA of RSX Length') smaRSX = ta.ema(rsx, len_sma) emaRSX = ta.ema(rsx, len_ema) //------------------------------------------------------------------- //---- Pivots and Libertus Divergences Component hb = math.abs(ta.highestbars(rsx, xbars)) // Finds bar with highest value in last X bars lb = math.abs(ta.lowestbars(rsx, xbars)) // Finds bar with lowest value in last X bars max = float(na) max_rsi = float(na) min = float(na) min_rsi = float(na) pivoth = bool(na) pivotl = bool(na) divbear = bool(na) divbull = bool(na) // If bar with lowest / highest is current bar, use it's value max := hb == 0 ? close : na(max[1]) ? close : max[1] max_rsi := hb == 0 ? rsx : na(max_rsi[1]) ? rsx : max_rsi[1] min := lb == 0 ? close : na(min[1]) ? close : min[1] min_rsi := lb == 0 ? rsx : na(min_rsi[1]) ? rsx : min_rsi[1] // Compare high of current bar being examined with previous bar's high // If curr bar high is higher than the max bar high in the lookback window range if close > max // we have a new high max := close // change variable "max" to use current bar's high value max if rsx > max_rsi // we have a new high max_rsi := rsx // change variable "max_rsi" to use current bar's RSI value max_rsi if close < min // we have a new low min := close // change variable "min" to use current bar's low value min if rsx < min_rsi // we have a new low min_rsi := rsx // change variable "min_rsi" to use current bar's RSI value min_rsi // Finds pivot point with at least 2 right candles with lower value pivoth := max_rsi == max_rsi[2] and max_rsi[2] != max_rsi[3] ? true : na pivotl := min_rsi == min_rsi[2] and min_rsi[2] != min_rsi[3] ? true : na // Detects divergences between price and indicator with 1 candle delay so it filters out repeating divergences if max[1] > max[2] and rsx[1] < max_rsi and rsx <= rsx[1] divbear := true divbear if min[1] < min[2] and rsx[1] > min_rsi and rsx >= rsx[1] divbull := true divbull //------------------------------------------------------------------- //---- Secondary Divergence Component for RSX + LSMA-D (Neobutane Divergences) k = rsx k2 = lsmaD //---- uselog = true // input(true, title="Log") //@RicardoSantos' Divergence Script (https://www.tradingview.com/script/3oeDh0Yq-RS-Price-Divergence-Detector-V2/) //---- fractal_top = f_fractalize(k) > 0 ? k[2] : na fractal_bot = f_fractalize(k) < 0 ? k[2] : na fractal_top2 = f_fractalize(k2) > 0 ? k2[2] : na fractal_bot2 = f_fractalize(k2) < 0 ? k2[2] : na high_prev = ta.valuewhen(fractal_top, k[2], 0)[2] high_price = ta.valuewhen(fractal_top, high[2], 0)[2] low_prev = ta.valuewhen(fractal_bot, k[2], 0)[2] low_price = ta.valuewhen(fractal_bot, low[2], 0)[2] high_prev2 = ta.valuewhen(fractal_top2, k2[2], 0)[2] high_price2 = ta.valuewhen(fractal_top2, high[2], 0)[2] low_prev2 = ta.valuewhen(fractal_bot2, k2[2], 0)[2] low_price2 = ta.valuewhen(fractal_bot2, low[2], 0)[2] regular_bearish_div = fractal_top and high[2] > high_price and k[2] < high_prev hidden_bearish_div = fractal_top and high[2] < high_price and k[2] > high_prev regular_bullish_div = fractal_bot and low[2] < low_price and k[2] > low_prev hidden_bullish_div = fractal_bot and low[2] > low_price and k[2] < low_prev regular_bearish_div2 = fractal_top2 and high[2] > high_price2 and k[2] < high_prev2 hidden_bearish_div2 = fractal_top2 and high[2] < high_price2 and k[2] > high_prev2 regular_bullish_div2 = fractal_bot2 and low[2] < low_price2 and k[2] > low_prev2 hidden_bullish_div2 = fractal_bot2 and low[2] > low_price2 and k[2] < low_prev2 col1 = regular_bearish_div ? #FF0000 : hidden_bearish_div and showhidden ? #FF0000 : na col2 = regular_bullish_div ? #00FF00 : hidden_bullish_div and showhidden ? #00FF00 : na col3 = regular_bearish_div ? #FF0000 : hidden_bearish_div and showhidden ? #FF0000 : showchan ? color.gray : na col4 = regular_bullish_div ? #00FF00 : hidden_bullish_div and showhidden ? #00FF00 : showchan ? color.gray : na col12 = regular_bearish_div2 ? #FF0000 : hidden_bearish_div2 and showhidden2 ? #FF0000 : na col22 = regular_bullish_div2 ? #00FF00 : hidden_bullish_div2 and showhidden2 ? #00FF00 : na col32 = regular_bearish_div2 ? #FF0000 : hidden_bearish_div2 and showhidden2 ? #FF0000 : showchan ? color.gray : na col42 = regular_bullish_div2 ? #00FF00 : hidden_bullish_div2 and showhidden2 ? #00FF00 : showchan ? color.gray : na //------------------------------------------------------------------- //---- M1/M2 and Trending Signal Alert componenent [Daveatt CCI Stoch] // showArrows = true // showArrowsEnter = true // showArrowsExit = true // showArrowsCenter = true trend_enter = if showArrowsEnter if ta.crossunder(rsx, m2Level) 1 else if ta.crossover(rsx, m1Level) -1 trend_exit = if showArrowsExit if ta.crossunder(rsx, m1Level) -1 else if ta.crossover(rsx, m2Level) 1 trend_center = if showArrowsCenter if ta.crossunder(rsx, 50) -1 else if ta.crossover(rsx, 50) 1 rsx_lsmaD_cu = rsx >= rsx_lsmaD_obLevel and ta.crossunder(rsx, lsmaD) rsx_lsmaD_co = rsx <= rsx_lsmaD_osLevel and ta.crossover(rsx, lsmaD) bool rsxBuy = rsxColor == #ff0000 bool rsxSell = rsxColor == #0ebb23 // } // Boom Pro { test = input.bool(false, "==================== Boom Pro Settings ====================", group = "Main Settings") theme = 'Dark' //, "Theme:", options=["Dark", "Light"], group = "Main Settings", inline = "main") showfib = false showentry = true square = input.bool(true, title='Square Line?', group='Main Settings') showdboom = true showlongs = true showshorts = true //showsignals = input(defval = false, title = "Show Alerts?", group = "Main Settings") //Quotient LPPeriod = input.int(6, title='Quotient | LPPeriod', inline='quotient', group='EOT 1 (Main Oscillator)') K1 = input.int(0, title='K1', inline='quotient', group='EOT 1 (Main Oscillator)') K2 = 0.3 esize = 60 //, title = "Size", inline = "quotient2", group = "EOT 1 (Main Oscillator)") ey = 50 //, title = "Y axis", inline = "quotient2", group = "EOT 1 (Main Oscillator)") trigno = input.int(2, 'Trigger Length', group='EOT 1 (Main Oscillator)', inline='quotient2') osccol = input.color(color.blue, title='Oscillator Color:', group='EOT 1 (Main Oscillator)', inline='q2') trigcol = input.color(color.white, title='Trigger Color:', group='EOT 1 (Main Oscillator)', inline='q2') // EOT 2 //Inputs LPPeriod2 = input.int(27, title='LPPeriod2', group='EOT 2 (Red Wave)', inline='q2') K12 = input.float(0.8, title='K1', group='EOT 2 (Red Wave)', inline='q2') K22 = input.float(0.3, title='K2', group='EOT 2 (Red Wave)', inline='q2') esize3 = 60 //, title = "Size", inline = "quotient2", group = "EOT 2 (Red Wave)") ey3 = 50 //, title = "Y axis2", inline = "quotient2", group = "EOT 2 (Red Wave)") osccol2 = input.color(color.red, title='Line Color:', inline='quotient22', group='EOT 2 (Red Wave)') osccol22 = input.color(color.red, title='Fill Color:', inline='quotient22', group='EOT 2 (Red Wave)') // EOT 3 //Inputs LPPeriod3 = input.int(11, title='LPPeriod3', group='EOT 3 (Yellow Line)', inline='q2') K13 = input.float(0.99, title='K1', group='EOT 3 (Yellow Line)', inline='q2') K33 = K13 * -1 esize2 = 60 //, title = "Size", inline = "quotient3", group = "EOT 3 (Yellow Line)") ey2 = 50 //, title = "Y axis", inline = "quotient3", group = "EOT 3 (Yellow Line)") osccol3 = input.color(color.yellow, title='Line Color:', group='EOT 3 (Yellow Line)', inline='quotient3') // LSMAWT n1 = input.int(9, 'WT | master', inline='lsma', group='LSMA Wave Trend Settings') n2 = input.int(6, 'time 1', inline='lsma', group='LSMA Wave Trend Settings') n3 = input.int(3, '2', inline='lsma', group='LSMA Wave Trend Settings') n4 = input.int(21, 'LSMA | 1', inline='LSMA', group='LSMA Wave Trend Settings') n5 = input.int(0, '2', inline='LSMA', group='LSMA Wave Trend Settings') smalen = 2 lsmaline = input.int(200, title='LSMA Long', group='LSMA Wave Trend Settings', inline='LSMA') if square K13 := 0.9999 K33 := -0.9999 K33 //FIB LINES //EOT 1 //Vars alpha1 = 0.00 HP = 0.00 a1 = 0.00 b1 = 0.00 c1 = 0.00 c2 = 0.00 c3 = 0.00 Filt = 0.00 Peak = 0.00 X = 0.00 Quotient1 = 0.00 Quotient2 = 0.00 pi = 2 * math.asin(1) //Highpass filter cyclic components //whose periods are shorter than 100 bars alpha1 := (math.cos(.707 * 2 * pi / 100) + math.sin(.707 * 2 * pi / 100) - 1) / math.cos(.707 * 2 * pi / 100) HP := (1 - alpha1 / 2) * (1 - alpha1 / 2) * (close - 2 * nz(close[1]) + nz(close[2])) + 2 * (1 - alpha1) * nz(HP[1]) - (1 - alpha1) * (1 - alpha1) * nz(HP[2]) //SuperSmoother Filter a1 := math.exp(-1.414 * pi / LPPeriod) b1 := 2 * a1 * math.cos(1.414 * pi / LPPeriod) c2 := b1 c3 := -a1 * a1 c1 := 1 - c2 - c3 Filt := c1 * (HP + nz(HP[1])) / 2 + c2 * nz(Filt[1]) + c3 * nz(Filt[2]) //Fast Attack - Slow Decay Algorithm Peak := .991 * nz(Peak[1]) if math.abs(Filt) > Peak Peak := math.abs(Filt) Peak //Normalized Roofing Filter if Peak != 0 X := Filt / Peak X Quotient1 := (X + K1) / (K1 * X + 1) Quotient2 := (X + K2) / (K2 * X + 1) // EOT 2 //Vars alpha1222 = 0.00 HP2 = 0.00 a12 = 0.00 b12 = 0.00 c12 = 0.00 c22 = 0.00 c32 = 0.00 Filt2 = 0.00 Peak2 = 0.00 X2 = 0.00 Quotient3 = 0.00 Quotient4 = 0.00 alpha1222 := (math.cos(.707 * 2 * pi / 100) + math.sin(.707 * 2 * pi / 100) - 1) / math.cos(.707 * 2 * pi / 100) HP2 := (1 - alpha1222 / 2) * (1 - alpha1222 / 2) * (close - 2 * nz(close[1]) + nz(close[2])) + 2 * (1 - alpha1222) * nz(HP2[1]) - (1 - alpha1222) * (1 - alpha1222) * nz(HP2[2]) //SuperSmoother Filter a12 := math.exp(-1.414 * pi / LPPeriod2) b12 := 2 * a12 * math.cos(1.414 * pi / LPPeriod2) c22 := b12 c32 := -a12 * a12 c12 := 1 - c22 - c32 Filt2 := c12 * (HP2 + nz(HP2[1])) / 2 + c22 * nz(Filt2[1]) + c32 * nz(Filt2[2]) //Fast Attack - Slow Decay Algorithm Peak2 := .991 * nz(Peak2[1]) if math.abs(Filt2) > Peak2 Peak2 := math.abs(Filt2) Peak2 //Normalized Roofing Filter if Peak2 != 0 X2 := Filt2 / Peak2 X2 Quotient3 := (X2 + K12) / (K12 * X2 + 1) Quotient4 := (X2 + K22) / (K22 * X2 + 1) // EOT 3 //Vars alpha1333 = 0.12 HP3 = 0.00 a13 = 0.00 b13 = 0.00 c13 = 0.00 c33 = 0.00 c333 = 0.00 Filt3 = 0.00 Peak3 = 0.00 X3 = 0.00 Quotient5 = 0.00 Quotient6 = 0.00 alpha1333 := (math.cos(.707 * 2 * pi / 100) + math.sin(.707 * 2 * pi / 100) - 1) / math.cos(.707 * 2 * pi / 100) HP3 := (1 - alpha1333 / 3) * (1 - alpha1333 / 2) * (close - 2 * nz(close[1]) + nz(close[2])) + 2 * (1 - alpha1333) * nz(HP3[1]) - (1 - alpha1333) * (1 - alpha1333) * nz(HP3[2]) //SuperSmoother Filter a13 := math.exp(-1.414 * pi / LPPeriod3) b13 := 2 * a13 * math.cos(1.414 * pi / LPPeriod3) c33 := b13 c333 := -a13 * a13 c13 := 1 - c33 - c333 Filt3 := c13 * (HP3 + nz(HP3[1])) / 2 + c33 * nz(Filt3[1]) + c333 * nz(Filt3[2]) //Fast Attack - Slow Decay Algorithm Peak3 := .991 * nz(Peak3[1]) if math.abs(Filt3) > Peak3 Peak3 := math.abs(Filt3) Peak3 //Normalized Roofing Filter if Peak3 != 0 X3 := Filt3 / Peak3 X3 Quotient5 := (X3 + K13) / (K13 * X3 + 1) Quotient6 := (X3 + K33) / (K33 * X3 + 1) line1 = -0.9 // LSMAWT // Sources: src0 = open src1 = high src2 = low src3 = close src4 = hl2 src5 = hlc3 src6 = ohlc4 src7 = ta.tr vol = volume tci(src) => ta.ema((src - ta.ema(src, n1)) / (0.025 * ta.ema(math.abs(src - ta.ema(src, n1)), n1)), n2) + 50 mf(src) => 100.0 - 100.0 / (1.0 + math.sum(volume * (ta.change(src) <= 0 ? 0 : src), n3) / math.sum(volume * (ta.change(src) >= 0 ? 0 : src), n3)) willy(src) => 60 * (src - ta.highest(src, n2)) / (ta.highest(src, n2) - ta.lowest(src, n2)) + 80 csi(src) => math.avg(ta.rsi(src, n3), ta.tsi(src0, n1, n2) * 50 + 50) phoenix(src) => math.avg(tci(src), csi(src), mf(src), willy(src)) tradition(src) => math.avg(tci(src), mf(src), ta.rsi(src, n3)) // Indi FUnctions wt1_1 = tradition(src5) wt2_1 = ta.sma(wt1_1, 6) //wt5 = sma(j,6) // LSMA wt3 = ta.linreg(wt1_1, n4, n5) wt4 = ta.ema((wt1_1 - wt2_1) * 2 + 50, n3) trig = ta.sma(wt3, smalen) q3 = Quotient3 * esize + ey q4 = Quotient4 * esize + ey //Plot EOT q1 = Quotient1 * esize + ey q2 = Quotient2 * esize + ey trigger = ta.sma(q1, trigno) //Plot3 = plot(q1, color= theme == "Tartan" ? color.white : color.blue, linewidth =2,title = "Quotient 1") //PLOT LSMAWT ext1 = wt2_1 < 20 ? trigger + 9 : wt2_1 > 80 ? trigger - 9 : na //plot(wt3, color = color.gray, linewidth = 1, transp = 50) //plot(ext1, "Pressure", color = wt2_1<20 ? color.lime : wt2_1>80 ? color.red : na, style = plot.style_circles, linewidth = 2, transp = 10) //plot(osc == "LSMA Wave Trend" ? sma(wt3,smalen) : na, color= theme == "Tartan" ? color.blue : theme == "Classic" ? #ff6a00 : color.yellow, linewidth = 2) lsma = ta.linreg(wt3, lsmaline, 0) //lsma = linreg(rsi(close,13),lsmaline,0) //plot(lsma, color= color.gray, linewidth = 1,transp = 50) q5 = Quotient5 * esize2 + ey2 q6 = Quotient6 * esize2 + ey2 //Conditions sma200 = ta.sma(close, 200) entry = ta.crossunder(Quotient2, line1) color2 = Quotient1 <= -1 and Quotient2 <= -1 exit = ta.cross(Quotient1, Quotient2) and close > sma200 and Quotient1 > 0.5 over = ta.cross(Quotient5, Quotient6) and Quotient5 > 0.5 over2 = ta.crossover(Quotient5, Quotient6) and Quotient5 > 0.5 over3 = ta.cross(Quotient3, Quotient4) and Quotient3 > 0 enter = ta.crossover(q1, trigger) and q1 < lsma // Breaks - luxalgo toggleBreaks = input.bool(false, title='Show Break Lines?', group='Support and Resistance Breaks') //track = input(true, title = "Show Price lines?", group = "Support and Resistance Breaks" ) leftBars = input.int(1, title='Resistance | Left Bars ', group='Support and Resistance Breaks', inline='2') rightBars = input.int(1, title='Right Bars', group='Support and Resistance Breaks', inline='2') //toggleBreaks2 = input(false, title = "Show Resistance", group = "Support and Resistance Breaks" ) leftBars2 = input.int(5, title='Support (Long) | Left Bars ', group='Support and Resistance Breaks', inline='3') rightBars2 = input.int(5, title='Right Bars', group='Support and Resistance Breaks', inline='3') //toggleBreaks3 = input(false, title = "Show Support (long)", group = "Support and Resistance Breaks" ) leftBars3 = input.int(1, title='Support (Short) |Left Bars ', group='Support and Resistance Breaks', inline='4') rightBars3 = input.int(1, title='Right Bars', group='Support and Resistance Breaks', inline='4') //toggleBreaks4 = input(false, title = "Show Support (Short)", group = "Support and Resistance Breaks" ) highUsePivot = fixnan(ta.pivothigh(q1, leftBars, rightBars)[1]) lowUsePivot = fixnan(ta.pivotlow(q1, leftBars2, rightBars2)[1]) lowUsePivot2 = fixnan(ta.pivotlow(q1, leftBars3, rightBars3)[1]) highUsePivot2 = fixnan(ta.pivothigh(q1, leftBars3, rightBars3)[1]) crossover = ta.crossover(q1, trigger) crossunder = ta.crossunder(q1, trigger) //VAR var ubreak = 0 var ubreak2 = 0 var dbreak = 0 var cont = 0 var cont2 = 0 var pull = 0 var dbreak2 = 0 var cross = 0 if crossunder cross := 0 cross if crossover cross := 1 cross if ta.crossunder(q1, lowUsePivot) dbreak += 1 dbreak if entry dbreak := 0 dbreak2 := 0 ubreak := 0 ubreak2 := 0 cont := 0 cont2 := 0 cont2 //if dbreak > 2 // dbreak := 0 volcond = ta.linreg(volume, 20, 0) var drag = 0 if Quotient1 <= -1 drag += 1 drag if ta.crossover(Quotient1, -0.9) drag := 0 drag if ta.crossover(q1, highUsePivot) and dbreak >= 1 ubreak += 1 ubreak dragno = input(3) if ta.crossover(q1, highUsePivot) and dbreak >= 1 and ubreak <= 1 cont := 1 cont if ta.crossover(q1, highUsePivot) and dbreak >= 2 and ubreak >= 2 and cont <= 2 cont2 := 1 cont2 if ta.crossunder(q1, lowUsePivot2) dbreak2 += 1 dbreak2 if ta.crossunder(q1, highUsePivot2) ubreak2 += 1 ubreak2 if ta.crossunder(q1, lowUsePivot2) and dbreak2 == 1 ubreak2 := 0 ubreak2 warn = ta.crossover(Quotient3, -0.9) warn2 = ta.crossover(Quotient1, -0.9) warn3 = ta.crossunder(Quotient1, 0.9) enter2 = Quotient1 <= -0.9 and ta.crossover(q1, trigger) and ta.barssince(warn) <= 7 // and Quotient3 <= -0.6 // and close > sma // QUALITY ENTRIES enter3 = Quotient3 <= -0.9 and ta.crossover(q1, trigger) and ta.barssince(warn2) <= 7 and q1 <= 20 and ta.barssince(ta.crossover(q1, 20)) <= 21 // and Quotient3 <= -0.6 // and close > sma // QUALITY ENTRIES entercond = ta.crossover(q1, trigger) and q1 < 10 enter4 = q1 <= 20 and ta.barssince(entercond) <= 5 and ta.crossover(q1, trigger) enter5 = ta.barssince(q1 <= 0 and ta.crossunder(q1, trigger)) <= 5 and ta.crossover(q1, trigger) enter6 = ta.barssince(q1 <= 20 and ta.crossunder(q1, trigger)) <= 11 and ta.crossover(q1, trigger) enter7 = Quotient3 <= -0.9 and ta.crossover(q1, trigger) //shorts senter3 = Quotient3 >= -0.9 and ta.crossunder(q1, trigger) and ta.barssince(warn3) <= 7 and q1 >= 99 and ta.barssince(ta.crossover(q1, 80)) <= 21 // and Quotient3 <= -0.6 // and close > sma // QUALITY ENTRIES bool boomProBuy = enter3 or enter5 or enter7 bool boomProSell = senter3 // } // Logic { bool buy = vmcBuy and rsxBuy and (boomProBuy or boomProBuy[1]) bool sell = vmcSell and rsxSell and (boomProSell or boomProSell[1]) plotshape(buy, "Buy", shape.labelup, location.belowbar, color.green, text = "Buy", textcolor = color.white, size = size.small) plotshape(sell, "Sell", shape.labeldown, location.abovebar, color.red, text = "Sell", textcolor = color.white, size = size.small) alertcondition(buy, "Buy") alertcondition(sell, "Sell") // }