Как разъединить 3 гистограммы оконного индикатора pinescript?
я решил объединить 3 одинаковых индикатора MACD, но с разными значениями в один индикатор, но при их соединении гистограммы наложились друг на друга. я не занимаюсь программированием, просто возникла необходимость.
//@version=5
indicator(title="Moving Average Convergence Divergence", shorttitle="MACD", timeframe="", timeframe_gaps=true)
// Getting inputs
fast_length = input(title = "Fast Length", defval = 5)
slow_length = input(title = "Slow Length", defval = 8)
src = input(title = "Source", defval = close)
signal_length = input.int(title = "Signal Smoothing", minval = 1, maxval = 50, defval = 9, display = display.data_window)
sma_source = input.string(title = "Oscillator MA Type", defval = "EMA", options = ["SMA", "EMA"], display = display.data_window)
sma_signal = input.string(title = "Signal Line MA Type", defval = "EMA", options = ["SMA", "EMA"], display = display.data_window)
// Calculating
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
alertcondition(hist[1] >= 0 and hist < 0, title = 'Rising to falling', message = 'The MACD histogram switched from a rising to falling state')
alertcondition(hist[1] <= 0 and hist > 0, title = 'Falling to rising', message = 'The MACD histogram switched from a falling to rising state')
hline(0, "Zero Line", color = color.new(#787B86, 50))
plot(hist, title = "Histogram", style = plot.style_columns, color = (hist >= 0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #FF5252)))
// Getting inputs
fast__length = input(title = "Fast Length", defval = 13)
slow__length = input(title = "Slow Length", defval = 21)
src2 = input(title = "Source", defval = close)
signal__length = input.int(title = "Signal Smoothing", minval = 1, maxval = 50, defval = 9, display = display.data_window)
sma__source = input.string(title = "Oscillator MA Type", defval = "EMA", options = ["SMA", "EMA"], display = display.data_window)
sma__signal = input.string(title = "Signal Line MA Type", defval = "EMA", options = ["SMA", "EMA"], display = display.data_window)
// Calculating
fast__ma = sma__source == "SMA" ? ta.sma(src2, fast__length) : ta.ema(src2, fast__length)
slow__ma = sma__source == "SMA" ? ta.sma(src2, slow__length) : ta.ema(src2, slow__length)
macd2 = fast__ma - slow__ma
signal2 = sma__signal == "SMA" ? ta.sma(macd2, signal__length) : ta.ema(macd2, signal__length)
hist2 = macd2 - signal2
alertcondition(hist2[1] >= 0 and hist2 < 0, title = 'Rising to falling', message = 'The MACD histogram switched from a rising to falling state')
alertcondition(hist2[1] <= 0 and hist2 > 0, title = 'Falling to rising', message = 'The MACD histogram switched from a falling to rising state')
hline(0, "Zero Line", color = color.new(#787B86, 50))
plot(hist2, title = "Histogram", style = plot.style_columns, color = (hist2 >= 0 ? (hist2[1] < hist2 ? #26A69A : #B2DFDB) : (hist2[1] < hist2 ? #FFCDD2 : #FF5252)))
fast_length3 = input(title = "Fast Length", defval = 34)
slow_length3 = input(title = "Slow Length", defval = 144)
src3 = input(title = "Source", defval = close)
signal_length3 = input.int(title = "Signal Smoothing", minval = 1, maxval = 50, defval = 9, display = display.data_window)
sma_source3 = input.string(title = "Oscillator MA Type", defval = "EMA", options = ["SMA", "EMA"], display = display.data_window)
sma_signal3 = input.string(title = "Signal Line MA Type", defval = "EMA", options = ["SMA", "EMA"], display = display.data_window)
// Calculating
fast_ma3 = sma_source3 == "SMA" ? ta.sma(src3, fast_length3) : ta.ema(src3, fast_length3)
slow_ma3 = sma_source3 == "SMA" ? ta.sma(src3, slow_length3) : ta.ema(src3, slow_length3)
macd3 = fast_ma3 - slow_ma3
signal3 = sma_signal3 == "SMA" ? ta.sma(macd3, signal_length3) : ta.ema(macd3, signal_length3)
hist3 = macd3 - signal3
alertcondition(hist3[1] >= 0 and hist3 < 0, title = 'Rising to falling', message = 'The MACD histogram switched from a rising to falling state')
alertcondition(hist3[1] <= 0 and hist3 > 0, title = 'Falling to rising', message = 'The MACD histogram switched from a falling to rising state')
hline(0, "Zero Line", color = color.new(#787B86, 50))
plot(hist3, title = "Histogram", style = plot.style_columns, color = (hist3 >= 0 ? (hist3[1] < hist3 ? #26A69A : #B2DFDB) : (hist3[1] < hist3 ? #FFCDD2 : #FF5252)))