K Line Pow Moving Average Convergence Divergence
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © lihulu123

//@version=5
indicator(title="K Line Pow Moving Average Convergence Divergence", shorttitle="KLinePowMACD",max_boxes_count=40000,max_bars_back=500)
// Getting inputs

fast_length = input(title="Fast Length", defval=12)
slow_length = input(title="Slow Length", defval=26)
src = input(title="Source", defval=close)

signal_length = input.int(title="Signal Smoothing",  minval = 1, maxval = 50, defval = 9)
sma_source = input.string(title="Oscillator MA Type",  defval="EMA", options=["SMA", "EMA"])
sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"])

// Plot colors

col_macd = input(#FFFFFF, "MACD Line", group="Color Settings", inline="MACD")
col_signal = input(#fbff0d, "Signal Line", group="Color Settings", inline="Signal")
col_green_zhuzi_shiti = input(color.new(#089981, 0), "MACD柱子", group="MACD BAR", inline="Above")
col_green_zhuzi_kong = input(color.new(#089981, 100), "MACD柱子", group="MACD BAR", inline="Above")
col_red_zhuzi_shiti = input(color.new(#FF5252, 0), "MACD柱子", group="MACD BAR", inline="Below")
col_red_zhuzi_kong = input(color.new(#FF5252, 100), "MACD柱子", group="MACD BAR", inline="Below")
// Calculating

col_green_boder = input(color.new(#089981, 0), "Fall", group="MACD BODER", inline="Above")
col_red_boder = input(color.new(#FF5252, 0), "Fall", group="MACD BODER", inline="Below")



fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = (macd - signal)*2
hline(0, "Zero Line", color=color.new(#787B86, 50))

plot(macd, title="白线", color=col_macd)
plot(signal, title="黄线", color=col_signal)
plotcandle(hist,0 , 0, 0,bordercolor=(hist>=0 ? col_green_boder : col_red_boder),color = (hist>=0 ? (hist[1] < hist ? col_green_zhuzi_kong : col_green_zhuzi_shiti) : (hist[1] < hist ? col_red_zhuzi_kong : col_red_zhuzi_shiti)))

