// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © maruful_bd_yhoo //@version=5 indicator("", overlay = true, explicit_plot_zorder = true) // Features of this script: // (1) Stochastic // (2) CVD // USE 1H chart for this script to give best signals. //_______ Inputs _______ l1 = input(4, "Smallest Base Lookback") l2 = l1 * 2 l3 = l1 * 3 l4 = int(l1 * 4.5) l5 = l1 * 5 l6 = l1 * 6 l7 = l6 * 3 l9 = l1 * 9 lookback = 0 length = 0 ltf_delta = 0.0 //=== Show/hide specific indicators show_stochK = input(false, "Stoch K?", "Show Stochastic K-line?") show_stochDS = input(false, "Show Double Smoothed Stoch?") show_30mRotation = input(false, "Show 30m Rot. ?") show_spot_cvd = input(false, "Show SPOT CVD?") barcolor_delta_based = input(false, "Color bars : delta compared?", "Color bars based on comparing Delta(last bar) against CVD") //=== Colors bullish = input.color( color.rgb(230, 230, 230), "Universal Bullish", "Universal bullish color used across the script") bearish = input.color( color.rgb(102, 204, 255), "Universal Bearish", "Universal bearish color used across the script") bullish2 = color.rgb(57,255,20) bearish2 = color.rgb(204,85,0) bull_grad_top = input.color(color.rgb(0, 204, 153), "Bull Gradient 1") bull_grad_bottom = input.color( color.rgb(51, 153, 102), "Bull Gradient 2") bear_grad_top = input.color(color.rgb(255, 51, 0), "Bear Gradient Top") bear_grad_bottom = input.color(color.rgb(204, 0, 102), "Bear Gradient Bottom") cvd_barcolor1 = input.color(color.rgb(63,255,0), "CVD Bullish Bar") cvd_barcolor2 = input.color(color.rgb(195,33,72), "CVD Bearish Bar") //----Normalization Function n(s,l) => hi = ta.highest(s, l) lo = ta.lowest(s, l) n = (s - lo) / (hi - lo)+1 n // Delta calculation delta_function() => vbuy=0.0, vsell=0.0, d=0.0 if close > open vbuy := volume * math.abs( open/close -1 ) if close < open vsell := volume * math.abs( open/close -1 ) d := ta.cum(vbuy - vsell) d // Delta calculation with normalized volume delta_function_norm(length_x) => vbuy=0.0, vsell=0.0, d=0.0 vol_n = n(volume, length_x) if close > open vbuy := vol_n * math.abs( open/close -1 ) if close < open vsell := vol_n * math.abs( open/close -1 ) d := ta.cum(vbuy - vsell) d := ( n(d, length_x) - 1.5 ) * 2 cvd = ta.alma(d, length_x, 0.85, 7) cvd //ltf_delta_ar = request.security_lower_tf(syminfo.tickerid, "5", delta_function(), false) //_______ Colors _______ c1 = color.rgb(128,128,128) c2 = color.rgb(229,228,226) c3 = color.rgb(54,69,79) c4 = color.rgb(0,255,0) c5 = color.rgb(0,128,0) c6 = color.rgb(0,128,128) c7 = color.rgb(10,186,181) c8 = color.rgb(0,0,128) c9 = color.rgb(114, 184, 255) c10 = color.rgb(186,85,211) c11 = color.rgb(221, 95, 41) c12 = color.rgb(128,0,0) c13 = color.rgb(227,0,34) c14 = color.rgb(192,192,192, 30) c15 = color.rgb(211,211,211, 60) // ************************************************************************************* //____________________ 1. Stochastic ___________________________________________________ // 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 plot( show_stochDS ? dsStoch : na, color = color.rgb(244,196,48), linewidth=1, style = plot.style_line, display = display.all - display.status_line) // Stochastic stoch = ta.stoch(close, high, low, 12) //stoch := stoch/100 stoch_ma = ta.alma(stoch, 24, .85, 6) //plot(stoch_ma, color = color.lime, style = plot.style_circles) // Overbought or Oversold ? overbought = stoch >= 80 ? true : false oversold = stoch <= 20 ? true : false l14 = ta.lowest(14), h14 = ta.highest(14) k = (close - l14) / (h14 - l14) d = ta.sma(k, 3) k_ma = ta.ema(k, 12) k_rma = ta.rma(k_ma, 2) k_transparency = k_ma > k_rma ? 0 : 30 k_color = k_ma > k_rma ? bullish : bearish //plot( show_stochK ? k_ma : na, title="Stoch K", color = color.new( c7, 0 ), display = display.none ) //plot( show_stochK ? k_rma : na, title="Stoch K RMA", color = color.new( c11, 0 ), style = plot.style_line) //fill ( plot(k_ma, title="Stoch K", color = color.new( c7, 0 ), display = display.none ), plot(k_rma, title="Stoch K RMA", color = color.new( c11, 0 ), style = plot.style_line), color=k_color ) // Stochastic => 30 minutes stoch30 = ta.stoch(close, high, low, 6) // Stochastic => 2H stoch2h = ta.stoch(close, high, low, 24) color_stoch = stoch30>80 and stoch2h>80 ? color.rgb(206,255,0) : stoch30<20 and stoch2h<20 ? color.rgb(204,78,92) : na //__________________________ () MACD ____________________________________________________________________________________ [ macdLine_faster, signal_faster, _ ] = ta.macd(close, 12, 22, 7) color_macd = ta.rising(signal_faster, 3) ? bullish : bearish // ============= ============= ================ ================ ============== //=== CVD for scalping v1 scalp_cvd_len = input(72, "CVD SCalping length 1") scalp_ltf_length = input(1, "LTF Length for Scalping" ) cvd_ltf_scalp = request.security(syminfo.tickerid, "5", delta_function_norm(scalp_cvd_len), gaps=barmerge.gaps_off) col_cvd_scalp = ta.rising(cvd_ltf_scalp,2)? bullish2 : ta.falling(cvd_ltf_scalp, 2) ? bearish2 : color.rgb(229,228,226) //=== Experimental: LTF volume based cvd _______________________________________________________________________________ ltf_vol_ar = request.security_lower_tf(syminfo.tickerid, "5", volume, false) len9 = input(15, "Normal CVD length", "Length used for slow CVD") vol = ltf_vol_ar.sum() vol_n = n(vol, len9) b9 = 0.0, s9 = 0.0, d9 = 0.0 if close > open b9 := vol_n * math.abs(open / close - 1) b9 if close < open s9 := vol_n * math.abs(open / close - 1) s9 d9 := ta.cum(b9-s9) d9 := ( n(d9, len9) - 1.5 ) * 2 cvd_normal = ta.alma(d9, len9, 0.80, 7) normal_rma = ta.rma(cvd_normal, 2) // plot -> see bottom of this script //_______________________________________________________________________________________________ v00 = 0.0, b00 = 0.0, s00 = 0.0 d00 = 0.0 nd00 = 0.0 //____________ Fastest _____________________ //____________ Faster _____________________ //____________ Slow _____________________ //____________ Slower _____________________ //____________ Slowest _____________________ // CVD Fast h2 = input(7, "CVD LTF Length", tooltip = "Length used in LTF CVD") v00 := n(volume, h2) 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, h2) -1.5)*2.0 cvd_fast = ta.alma(nd00,h2,0.95,6) //=== CVD (cvd_fast) plot //cvd_color = cvd_rising ? color.lime : cvd_falling ? color.red : cvd_fast>0 ? color.green : color.maroon //plot(cvd_fast, color = ta.rising(cvd_fast, 2) and cvd_fast > 0 ? color.rgb(0,255,0, transperancy_rising) : ta.falling(cvd_fast, 2) and cvd_fast>0 ? color.rgb(220,20,60, transperancy_falling) : ta.falling(cvd_fast, 2) and cvd_fast<=0 ? color.rgb(220,20,60, transperancy_falling) : ta.rising(cvd_fast, 2) and cvd_fast<=0 ? color.rgb(0,255,0, transperancy_rising) : cvd_fast>0 ? color.rgb(0,255,0, 40) : color.rgb(220,20,60, 30), style = plot.style_areabr) //=== Color bars based on Delta vs. CVD color_delta_comparison = nd00 > cvd_fast ? bullish : bearish // ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= //_______ 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') // Setting bgcolor bgcolor( long ? #00BCD4 : short ? #FF5252 : color.rgb(0,0,0) ) //////////////////////////////////////////////////////////////////// /////// SPOT CVD symbol_ = str.replace(syminfo.tickerid, "PERP", "") //symbol_ := "BINANCE:" + symbol_ [open77, close77, vol_spot] = request.security(symbol_, "", [open, close, volume], ignore_invalid_symbol=false) //len77 = input(15, "Normal CVD length", "Length used for slow CVD") len77 = len9 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) //=== ADX by Tradingview len = input.int(17, minval=1, title="DI Length") lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50) [diplus, diminus, adx] = ta.dmi(len, lensig) trendStrength = adx>25 ? true : false //==================== 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") mult = input(2.0,title="BB MultFactor") lengthKC=input(20, title="KC Length") multKC = input(1.5, title="KC MultFactor") useTrueRange = input.bool(true, title="Use TrueRange (KC)") // 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.blue : sqzOn ? color.rgb(255,0,144) : bullish //____________________________________________________________________________ //=== Plots //____________________________________________________________________________ //=== Lines & Fills =========================================================== color1 = show_30mRotation ? nd01 > nd11 ? color.rgb(245,245,245) : color.rgb(245,245,245, 70) : color.rgb(245,245,245, 100) //fill(plot(nd01,'',color1),plot(nd11,'',color1),color=color1) rot1 = plot(show_30mRotation ? nd01 : na, '', color1) rot2 = plot( show_30mRotation ? nd11 : na, '', color1) fill(rot1, rot2, color = color1) hline_1 = hline(1,'1',#FF52528F,linestyle=hline.style_solid) hline75 = hline(0.75,'0.75',#FF52528F,linestyle=hline.style_dotted) fill( hline_1, hline75, color= nd00 < -0.75 and nd00 > nd10 ? #00BCD4CF : nd00 > 0.75 and nd00 < nd10 ? #FF5252CF : na) //hline(0,'0',#FFFFFF8F,linestyle=hline.style_solid) 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 ) //=== 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) : cvd_fast>0 ? color.new(bullish, transp) : color.new(bearish, transp) cvd_color2 = cvd_rising? color.from_gradient(cvd_fast, 0, 1, bull_grad_bottom, bull_grad_top) : cvd_falling ? color.from_gradient(cvd_fast, -1, 0, bear_grad_bottom, bear_grad_top) : cvd_fast>0 ? color.new(bull_grad_bottom, transp) : color.new(bear_grad_bottom, transp) plot( cvd_fast, title="", color = cvd_color, linewidth = 1, style = plot.style_area) //=== 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>normal_rma ? bullish : bearish transp_normal = cvd_normal >= 0 ? 50 - cvd_normal*50 : cvd_normal < 0 ? 50-math.abs(cvd_normal*50) : 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(bullish2, transp_normal) : cvd_falling_n ? color.new(bearish2, transp_normal) : color.rgb(255, 51, 204) //cvd_color_n = cvd_normal>0 ? color.new(bullish, transp_normal) : color.new(bearish, transp_normal) plot( cvd_normal, title="", color = cvd_color_n, linewidth = 3, style = plot.style_line, join=true) /////////////////////////////////////////////////////////////////////////////////////////////////// /////// SPOT CVD col_spot_cvd = ta.rising(cvd_spot, 2) ? color.rgb(255,255,0) : ta.falling(cvd_spot, 2) ? color.rgb(255,215,0) : color.black plot( show_spot_cvd ? 1 : na, "", color=col_spot_cvd, style = plot.style_circles) //=== MACD signal plot(0.75, title = "Sig.", color=color_macd, style = plot.style_circles, display = display.none) //=== Squeeze momentum plot(-1, title="SQ", color=scolor, style=plot.style_cross, linewidth=2, display = display.pane) //plot(-1, title="", color=bcolor, style=plot.style_cross, linewidth=1) //plot(-1, color=scolor, style=plot.style_cross, linewidth=1) //=== Stoch K plot( show_stochK ? 1 : na, title = "K", color = k_color, linewidth = 1, style = plot.style_cross, display = display.none) // CVD LTF based scalping //plot(cvd_ltf_scalp, "", color=col_cvd_scalp, style = plot.style_circles, join = true) //=== BG color & Bar color //bgcolor( trendStrength ? color.rgb(85,85,85, 35) : color.rgb(0,0,0) ) //bgcolor( color.rgb(0,0,0)) barcolor( barcolor_delta_based ? color_delta_comparison : na )