// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © calibrated89 //___________________________________________________________________________________________________________ // When to enter a position? // Bar turned Green -> CVD MA turned bullish -> LONG -> exit when CVD turns bearish // Bar turned Red -> SHORT -> exit when CVD MA turned bullish //___________________________________________________________________________________________________________ //@version=5 indicator("~CVD EMAs") // This source code is adapted from "Cummulative Volume Delta" by footlz lookback = input(72, title="CVD lookback [colored candles]") v = volume o = open c = close vbuy = 0.0 vsell = 0.0 if c > o vbuy := v * math.abs(o / c - 1) if c < o vsell := v * math.abs(o / c - 1) delta = ta.cum(vbuy - vsell) //_________________ colors c11 = color.rgb(248,248,255), c01 = color.rgb(132,132,130) c12 = color.rgb( 7, 236, 247 ), c02 = color.rgb(153,50,204) c13 = color.rgb(105, 247, 7), c03 = color.rgb(220,20,60) //_____________________________________________________________________ Tested plots. GOOD results !!! ema_ltf_3 = ta.ema(delta, 12) barcolor( color = delta > ema_ltf_3 ? c11 : color.rgb(255,0,144) ) // Tested. GOOD result!!! ema_ltf_2 = ta.ema( delta, 18) plot( ema_ltf_2, color = delta > ema_ltf_2 ? #ffffff : color.rgb(169,169,169, 60), style=plot.style_stepline) ema_ltf = ta.ema( delta, 24) plot( ema_ltf, color = delta > ema_ltf ? color.rgb(152,251,152) : color.rgb(164,0,0), style=plot.style_circles) //_____________________________________________________________________________________________________ ema = ta.ema( delta, 36) ema_rma = ta.rma(ema, 2) //plot(ema, color = ema > ema_rma ? c13 : c03) //_______ ALMA for extra confluence ___________________________________________________________________ alma_ltf_2 = ta.alma(delta, 40, 0.90, 6) bgcolor( delta > alma_ltf_2 ? color.rgb(0,116,116, 75) : color.rgb(101,0,11,65) )