// 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("~Sig", overlay = false) // Inputs fastest = input( 7, "Fastest lookback") faster = fastest * 2 slow = input( 20, "Slow lookback" ) slower = 24 slowest = int(slow * 1.5) signalLength_macd = input (7, "MACD signal length") signalLength_macd_fastest = input (4, "MACD signal length") // === Normalization norm( data, lookback) => max = ta.highest( data, faster ) min = ta.lowest( data, faster ) norm = ( data - min ) / ( max - min ) + 1 norm //=== Calculations [ macdLine, signal_fastest, _ ] = ta.macd(close, fastest, faster, signalLength_macd) [ macdLine_faster, signal_faster, _ ] = ta.macd(close, faster, slower, signalLength_macd) [macd2, signal_slowest, _] = ta.macd(close, faster, slowest, 7 ) // Smaller difference = Trend reversal dif_signal = signal_faster - signal_slowest //=============================== // colors ================= //=============================== bullish = input( #aaff00, "Bullish" ) bearish = input (#e60073, "Bearish" ) bearish_lite = #669999 bullish_simple = #00e600 bearish_simple = #666666 candle_bullish = #00ccff candle_bearish = #ff0080 candle_bearish_lite = #ffa64d bullish2 = #cccccc bearish2 = #ff3385 bull1 = #009900 bull2 = #ffff00 bear1 = #ff471a // === plotting === p_signal_fastest = plot(signal_fastest, title="Signal fastest", color= ta.rising( signal_fastest, 7) ? #faf0e6 : bearish, linewidth = 1, style=plot.style_circles) p_signal_faster = plot(signal_faster, title="MACD signal slow", color= ta.rising(signal_faster, 7) ? #c4ff4d : #e60000 , linewidth = 1) //p_signal_slowest = plot(signal_slowest, title="MACD signal fastestest", color= ta.rising(signal_slowest, 4) ? bullish2 : bearish2 , linewidth = 1, style=plot.style_stepline) //fill ( p_signalLine, p_signalLine2, color = ta.rising( signalLine2, 7) ? bullFill1 : bearFill1) // === Reverse MACD [ _, rev_macdLine_original, _] = ta.macd(close, 33, 7, signalLength_macd) [ macdLine2, rev_macdLine2_original, _] = ta.macd(close, 14, 7, signalLength_macd) rev_macdLine = rev_macdLine_original rev_macdLine2 = rev_macdLine2_original //p_rev_macdLine = plot( rev_macdLine, title = "Rev. MACD", color= ta.rising( rev_macdLine, 7) ? bearish : bullish, linewidth = 1 ) //p_rev_macdLine2 = plot( rev_macdLine2, title = "Rev. MACD", color= ta.rising( rev_macdLine2, 3) ? bearish : bullish, linewidth = 1, style= plot.style_circles ) //fill( p_rev_macdLine, p_rev_macdLine2, color = ta.rising( rev_macdLine2, 7) ? bearFill2 : bullFill2 ) //======================================= // Stoch RSI //======================================= rsi7 = ta.stoch( close, high, low, 7) rsi14 = ta.stoch( close, high, low, 14) rsi_dif = rsi7 - rsi14 //plot( rsi_dif, color = #3366cc) //=== Color candles based on price action fastest2 = input( 7, "Short EMA lookback") slow2 = input( 14, "Medium EMA lookback") ema_high = ta.ema( high, 7) ema_medium = ta.ema( close, slow2) ema_fastest = ta.ema( close, 6) ema_low_fastest = ta.ema( low, fastest2 ) //==== color the candlesticks //barcolor( close > ema_medium ? candle_bullish : close <= ema_fastest ? candle_bearish : candle_bearish_lite ) b01 = 0.0, s01 = 0.0 vol_norm = norm( volume, 12) // Buy volume if close > open b01 := vol_norm * math.abs(open / close) b01 // Sell volume if close < open s01 := vol_norm * math.abs(open / close) s01 d00_ = ta.cum(b01 - s01) cvd_ma = ta.alma(d00_, 12, .80, 5) //cvd_ma = ta.sma(d00_, 11) barcolor( d00_ > cvd_ma ? #004953 : #8a795d )