// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © pablo_escobar //@version=5 indicator("", overlay = false, explicit_plot_zorder = true) //// Constants color LIME = color.rgb(140, 255, 26) color GREEN = color.rgb(0, 230, 0) color CYAN = color.rgb(60,179,113) color RED = color.rgb(255,69,0) color CRIMSON = color.rgb(220,20,60) color MAROON = color.rgb(255, 0, 102) color BLUE = color.rgb(31,117,254) color YELLOW = color.rgb(255,255,102) color PURPLE = color.rgb(255, 15, 235) c1 = color.rgb(0, 153, 153) c2 = color.rgb(51, 102, 153) c4 = color.rgb(0,255,0) c5 = color.rgb(0,128,0) c6 = color.rgb(0,128,128) c7 = color.rgb(255,69,0) c8 = color.rgb(0,0,128) c9 = color.rgb(114, 184, 255) c11 = color.rgb(90, 90, 90) c12 = color.rgb(43, 43, 43) //// Variables Initialization //// Normal Speed CVD //// ltf_vol_ar = request.security_lower_tf(syminfo.tickerid, "1", volume, false) length := input(24, "Normal CVD length", "Length used for Normal CVD", group = "CVD") vol = ltf_vol_ar.sum() vol_n = n(vol, length) vol_buy := 0.0, vol_sell := 0.0, vol_delta := 0.0 [open_ltf_ar, close_ltf_ar] = request.security_lower_tf(syminfo.tickerid, "1", [open, close]) open_ltf = array.sum(open_ltf_ar) close_ltf = array.sum(close_ltf_ar) if close_ltf > open_ltf vol_buy := vol_n * math.abs(open_ltf / close_ltf - 1) vol_buy if close_ltf < open_ltf vol_sell := vol_n * math.abs(open_ltf / close_ltf - 1) vol_sell vol_delta := ta.cum(vol_buy-vol_sell) vol_delta := ( n(vol_delta, length) - 1.5 ) * 2 cvd_normal = ta.alma(vol_delta, length, 0.85, 7) rma_normal = ta.rma(cvd_normal, 2) //// CVD Fast //// //length := input.int(14, "Fast CVD Length", tooltip = "Length used in Fast CVD", group = "CVD") length := lenCVDFast vol_n := n(volume, length) [open_ltf_ar00, close_ltf_ar00] = request.security_lower_tf(syminfo.tickerid, "1", [open, close]) open_ltf := array.sum(open_ltf_ar00) close_ltf := array.sum(close_ltf_ar00) if close_ltf > open_ltf vol_buy := vol_n * math.abs(open_ltf / close_ltf - 1) vol_buy if close_ltf < open_ltf vol_sell := vol_n * math.abs(open_ltf / close_ltf - 1) vol_sell vol_delta := ta.cum(vol_buy - vol_sell) vol_delta := (n(vol_delta, length) -1.5)*2.0 cvd_fast = ta.alma(vol_delta,length,0.90,7) rma_fast = ta.rma(cvd_fast, 2) //// ALert : Bardelta v CVD //// bardelta := vol_delta cvd_bardelta = cvd_fast bardelta_diff = bardelta - cvd_bardelta alertLong01 = bardelta > cvd_bardelta ? true : false alertShort01 = bardelta < cvd_bardelta ? true : false //// peckerponzi original rotation //// //----Trigger Rotation lookback = l3 v00 := n(volume, lookback) if close > open b00 := v00 * math.abs(open / close - 1) b00 if close < open s00 := v00 * math.abs(open / close - 1) s00 d00 := ta.cum(b00 - s00) nd00 := (n(d00,lookback) -1.5)*2.0 nd00 := ta.alma(nd00,lookback,0.95,6) nd10 = ta.rma(nd00,2) //----Fast Rotation lookback := l9 v01 = n(volume,lookback) b01 = 0.0, s01 = 0.0 if close > open b01 := v01 * math.abs(open / close - 1) b01 if close < open s01 := v01 * math.abs(open / close - 1) s01 d01 = ta.cum(b01 - s01) nd01 = (n(d01,lookback) -1.5)*2.0 nd01 := ta.alma(nd01,lookback,0.90,6) nd11 = ta.rma(nd01,3) //----Basic Single Alert threshold = input(0.75,'Alert Threshold') long = ta.crossover(nd01,nd11) and nd01 <= - threshold and nd00 > nd10 short = ta.crossunder (nd01,nd11) and nd01 >= threshold and nd00 < nd10 cond = long or short bgcol = long ? #00BCD4 : short ? #FF5252 : na //bgcolor(vis_alert ? bgcol : na ,title='Alert Trigger') alertcondition(cond, title='Rotations X', message='Rotations X') //////////////////////////////////////////////////////////////////// /////// SPOT CVD symbol_ = str.replace(syminfo.tickerid, "PERP", "") [open77, close77, vol_spot] = request.security(symbol_, "1", [open, close, volume], ignore_invalid_symbol=false) len77 = input.int(12, "Spot CVD Length", group = "CVD") vol_n2 = n(vol_spot, len77) b77 = 0.0, s77 = 0.0, d77 = 0.0 if close > open b77 := vol_n2 * math.abs(open / close - 1) b77 if close < open s77 := vol_n * math.abs(open / close - 1) s77 d77 := ta.cum(b77-s77) d77 := ( n(d77, len77) - 1.5 ) * 2 cvd_spot = ta.alma(d77, len77, 0.80, 7) spot_rma = ta.rma(cvd_spot, 2) // Double smoothed stoch lowest_low = ta.lowest(12) x = close - lowest_low ema00 = ta.ema(x, 12) ema0 = ta.ema(ema00, 12) highest_high = ta.highest(12) y = highest_high - lowest_low ema01 = ta.ema(y, 12) ema1 = ta.ema(ema01, 12) dsStoch = ema0 / ema1 rma_dsStoch = ta.rma(dsStoch, 2) //==================== Squeeze Momentum Indicator by LazyBear // Mr.Carter suggests waiting till the first gray after a black cross, and taking a position in the direction of the momentum (for ex., if momentum value is above zero, go long). Exit the position when the momentum changes (increase or decrease --- signified by a color change). My (limited) experience with this shows, an additional indicator like ADX / WaveTrend, is needed to not miss good entry points. length := input(20, title="BB Length", group = "Squeeze Momentum") mult = input(3.0,title="BB MultFactor", group = "Squeeze Momentum") lengthKC=input(16, title="KC Length", group = "Squeeze Momentum") multKC = input(1.5, title="KC MultFactor", group = "Squeeze Momentum") useTrueRange = input.bool(true, title="Use TrueRange (KC)", group = "Squeeze Momentum") // Calculate BB source = close basis = ta.sma(source, length) dev = mult * ta.stdev(source, length) upperBB = basis + dev lowerBB = basis - dev // Calculate KC ma = ta.sma(source, lengthKC) range0 = useTrueRange ? ta.tr : (high - low) rangema = ta.sma(range0, lengthKC) upperKC = ma + rangema * multKC lowerKC = ma - rangema * multKC sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC) sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC) noSqz = (sqzOn == false) and (sqzOff == false) val = ta.linreg(source - math.avg(math.avg(ta.highest(high, lengthKC), ta.lowest(low, lengthKC)), ta.sma(close,lengthKC)), lengthKC,0) //color bcolor = na bcol1 = val > nz(val[1]) ? bullish : color.new(bullish, 50) bcol2 = val < nz(val[1]) ? bearish : color.new(bearish, 50) bcolor = val > 0 ? bcol1 : bcol2 scolor = noSqz ? color.gray : sqzOn ? color.rgb(255,0,144) : c4 //____________________________________________________________________________ //=== Plots //____________________________________________________________________________ //// 30 minutes Rotation //// color1 = show_30mRotation ? nd01 > nd11 ? color.rgb(245,245,245) : color.rgb(245,245,245, 70) : color.rgb(245,245,245, 100) //rot1 = plot(show_30mRotation ? nd01 : na, '', color1) //rot2 = plot( show_30mRotation ? nd11 : na, '', color1) //fill(rot1, rot2, color = color1) // Lines & Fills //// hline_1 = hline(1,'',color.rgb(200, 100, 100, 100),linestyle=hline.style_solid) hline75 = hline(0.80, '', color.rgb(211, 211, 181, 100),linestyle=hline.style_dotted) fill( hline_1, hline75, color= long ? bullish3 : short ? bearish3 : nd00 < -0.75 and nd00 > nd10 ? color.new(bullish3, 90) : nd00 > 0.75 and nd00 < nd10 ? color.new(bearish3, 90) : na) //// ALert : based on CVD Fast //// hline_m1 = hline(-1,'',color.rgb(200, 100, 100, 100),linestyle=hline.style_solid) hline_m2 = hline(-0.80, '', color.rgb(211, 211, 181, 100),linestyle=hline.style_dotted) fill( hline_m1, hline_m2, color= alertLong00 ? bullish2 : alertShort00 ? bearish3 : na) //hline_m1 = hline(-0.75,'-0.75',#00BCD48F,linestyle=hline.style_dotted) //hline_m75 = hline(-1,'-1',#00BCD48F,linestyle=hline.style_solid) //=== Ketler channel/Bollinger Band //fill( hline_m1, hline_m75, color = bcolor ) //// Stoch: Double smoothed //// col_dsStoch_bull = ta.rising(dsStoch, 2) ? BLUE : na col_dsStoch_bear = ta.falling(dsStoch, 2) ? PURPLE : na plot( showDSStoch ? 1 : na, color = col_dsStoch_bull, style = plot.style_cross) plot( showDSStoch ? 1 : na, color = col_dsStoch_bear, style = plot.style_cross) //// CVD normal ( aka cvd_normal) //// //col_normal = cvd_normal>normal_rma ? color.from_gradient(cvd_fast, 0, 1, bull_grad_bottom, bull_grad_top) : color.from_gradient(cvd_fast, -0.1, -1, bear_grad_bottom, bear_grad_top) col_normal = cvd_normal>rma_normal ? bullish : bearish transp_normal = cvd_normal >= 0 ? 60 - cvd_normal*60 : cvd_normal < 0 ? 60-math.abs(cvd_normal*60) : 100 cvd_rising_n = cvd_normal >-0.90 and ta.rising(cvd_normal, 2) ? true : false cvd_falling_n = cvd_normal < 0.90 and ta.falling(cvd_normal, 2) ? true : false //cvd_color_n = cvd_rising_n ? color.new(bullish3, transp_normal) : cvd_falling_n ? color.new(bearish3, transp_normal) : na cvd_color_n = cvd_rising_n ? color.from_gradient(cvd_normal, -1, 1, bearish3, bullish3) : cvd_falling_n ? color.from_gradient(cvd_normal, -1, 1, bearish3, bullish3) : na plot_cvd_normal = plot( show_cvd_normal ? cvd_normal : na, title="", color = cvd_color_n, linewidth = 1, style = plot.style_line, join=true) plot_rma_normal = plot( show_cvd_normal ? rma_normal : na, title="", color = cvd_color_n, linewidth = 1, style = plot.style_line, join=true) fill( plot_cvd_normal, plot_rma_normal, color = cvd_color_n ) //// CVD fast //// transp = cvd_fast >= 0 ? 50 - cvd_fast*50 : cvd_fast < 0 ? 50-math.abs(cvd_fast*50) : 100 cvd_rising = ta.rising(cvd_fast, 2) ? true : false cvd_falling = ta.falling(cvd_fast, 2) ? true : false //cvd_color = cvd_rising ? color.new(bullish, transp) : cvd_falling ? color.new(bearish, transp) : color.new(color.rgb(255, 215, 0), 100) cvd_color = cvd_rising ? color.from_gradient(cvd_fast, -1, 1, bearish2, bullish2) : cvd_falling ? color.from_gradient(cvd_fast, -1, 1, bearish2, bullish2) : color.yellow plot_cvd_fast = plot( show_cvd_fast ? cvd_fast : na, title="", color = cvd_color, linewidth = 1, style = plot.style_line) plot_cvd_rma = plot( show_cvd_fast ? rma_fast : na, title="", color = cvd_color, linewidth = 1, style = plot.style_line) fill( plot_cvd_fast, plot_cvd_rma, color=cvd_color ) //// SPOT CVD //// col_spot_cvd = ta.rising(cvd_spot, 2) ? CYAN : ta.falling(cvd_spot, 2) ? color.rgb(255,69,0) : color.rgb(248,248,255) plot( show_spot_cvd ? 0.75 : na, "", color=col_spot_cvd, style = plot.style_circles, display = display.pane) //// Squeeze momentum //// plot( showSqueezeMomentum ? -0.90 : na, title="SQ", color=scolor, style=plot.style_cross, linewidth=1, display = display.pane) //plot(-1, title="", color=bcolor, style=plot.style_cross, linewidth=1) //plot(-1, color=scolor, style=plot.style_cross, linewidth=1) //// RMA Alert : CVD & RMA comparison col_rma_alert = cvd_fast > rma_fast ? c4 : c7 plot( show_rma_alert ? 0 : na, 'CVD - RMA comparison', color=col_rma_alert, linewidth = 1, style = plot.style_cross, display = display.pane) //// BG color & Bar color //// bgcolor( alertShort01 ? color.from_gradient(bardelta, -1, 1, c12, c11) : alertLong01 ? color.from_gradient(bardelta, -1, 1, c12, c11) : na)