// 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("~ALL", overlay = true, explicit_plot_zorder = true) // Features of this script: // (1) CVD // (2) Stochastic // 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 ltf_delta = 0.0 buy = false, sell = false // 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 //ltf_delta_ar = request.security_lower_tf(syminfo.tickerid, "3", delta_function(volume), false) //----Normalization Function n(s,l) => hi = ta.highest(s, l) lo = ta.lowest(s, l) n = (s - lo) / (hi - lo)+1 n //_______ 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) ltf_delta_ar = request.security_lower_tf(syminfo.tickerid, "3", delta_function(), false) delta = ltf_delta_ar.sum() delta := ( n(delta, 6) - 1.5 ) * 2 cvd_ma = ta.alma(delta, 30, 0.85, 6) //cvd_rma = ta.rma(cvd_ma, 3) //cvd_ema = ta.ema(delta, l4) //plot( cvd_ma, color = cvd_ma > cvd_rma ? color.lime : color.red) v00 = 0.0, b00 = 0.0, s00 = 0.0 d00 = 0.0 nd00 = 0.0 //____________ Fastest _____________________ //____________ Faster _____________________ //____________ Slow _____________________ //____________ Slower _____________________ //____________ Slowest _____________________ // H2 chart CVD h2 = 7 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 ma_h2 = ta.alma(nd00,h2,0.95,6) plot(ma_h2, color = ta.rising(ma_h2, 2) ? color.rgb(192,192,192, 30) : color.rgb(211,211,211, 70), style = plot.style_areabr) //_______ 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) // Price and volume change comparison vol_bullish = nd00 > nd10 ? true : na vol_bearish = nd10 > nd00 ? true : na if vol_bearish and ta.falling(ma_h2, 2) sell := true if vol_bullish and ta.rising(ma_h2, 2) buy := true //barcolor( vol_bearish ? color.rgb(255,165,0) : vol_bullish ? color.rgb(0,191,255) : na) //========================================================================================= color1 = nd01 > nd11 ? color.rgb(245,245,245) : color.rgb(245,245,245, 70) fill(plot(nd01,'Fast Rotation',color1),plot(nd11,'Smooth Fast Rotation',color1),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) fill( hline_m1, hline_m75, color= na) //----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') //____________________ 2. Stochastic ___________________________ // 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 >= 0.8 ? true : false oversold = stoch <= 0.2 ? true : false //bgcolor( color = stoch >= 0.8 ? color.rgb(195,33,72, 30) : stoch <= 0.2 ? color.rgb(152,251,152, 40) : na) 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 : 60 k_color = k_ma > k_rma ? color.white : c15 fill ( plot(k_ma, title="Stoch K", color = color.new( #FFFFFFFF, k_transparency ) ), plot(k_rma, title="Stoch K RMA", color = color.new( #FFFFFFFF, k_transparency ), style = plot.style_line), color=color.new( #FFFFFFFF, k_transparency ) ) // Sell & Buy signal ? sell_sig = overbought and ta.crossunder(k,d) buy_sig = oversold and ta.crossover(k,d) // 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(dsStoch, color = color.rgb(244,196,48), style = plot.style_circles) stoch_bullish = k>d and k_ma > k_rma ? true : false stoch_bearish = k