两条线之间的颜色
Color between 2 lines
我使用 MACD,我想 :
在macd_color
和signal_color
两行之间:
macd 高于信号时为绿色
当 macd 低于信号时红色
study(title="MACD V5", shorttitle="MACD V5")
source = close
useCurrentRes = input(true, title="Use Current Chart Resolution?")
resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=resolution,
defval="60")
smd = input(true, title="Show MacD & Signal Line? Also Turn Off Dots Below")
sd = input(true, title="Show Dots When MacD Crosses Signal Line?")
sh = input(true, title="Show Histogram?")
macd_colorChange = input(true,title="Change MacD Line Color-Signal Line Cross?")
hist_colorChange = input(true,title="MacD Histogram 4 Colors?")
res = useCurrentRes ? period : resCustom
fastLength = input(12, minval=1), slowLength=input(26,minval=1)
signalLength=input(9,minval=1)
fastMA = ema(source, fastLength)
slowMA = ema(source, slowLength)
macd = fastMA - slowMA
signal = sma(macd, signalLength)
hist = macd - signal
outMacD = security(tickerid, res, macd)
outSignal = security(tickerid, res, signal)
outHist = security(tickerid, res, hist)
histA_IsUp = outHist > outHist[1] and outHist > 0
histA_IsDown = outHist < outHist[1] and outHist > 0
histB_IsDown = outHist < outHist[1] and outHist <= 0
histB_IsUp = outHist > outHist[1] and outHist <= 0
//MacD Color Definitions
macd_IsAbove = outMacD >= outSignal
macd_IsBelow = outMacD < outSignal
plot_color = hist_colorChange ? histA_IsUp ? aqua : histA_IsDown ? blue : histB_IsDown ? red :
histB_IsUp ? maroon :yellow :gray
macd_color = macd_colorChange ? macd_IsAbove ? lime : red : red
signal_color = macd_colorChange ? macd_IsAbove ? yellow : yellow : lime
circleYPosition = outSignal
plot(smd and outMacD ? outMacD : na, title="MACD", color=macd_color, linewidth=2)
plot(smd and outSignal ? outSignal : na, title="Signal Line", color=signal_color, style=line
,linewidth=2)
plot(sh and outHist ? outHist : na, title="Histogram", color=plot_color, style=histogram,
linewidth=4)
plot(sd and cross(outMacD, outSignal) ? circleYPosition : na, title="Cross", style=circles,
linewidth=3, color=macd_color)
hline(0, '0 Line', linestyle=solid, linewidth=2, color=white)
band1 = hline(25, "Upper Band", color=#ff0000)
band0 = hline(-25, "Lower Band", color=#00ff0a)
完全不知道怎么做
你有 fill()
功能。
fill_color = outMacD > outSignal ? green : red
p_macd = plot(smd and outMacD ? outMacD : na, title="MACD", color=macd_color, linewidth=2)
p_sig = plot(smd and outSignal ? outSignal : na, title="Signal Line", color=signal_color, style=line ,linewidth=2)
fill(p_macd, p_sig, fill_color, 85)
我使用 MACD,我想 :
在macd_color
和signal_color
两行之间:
macd 高于信号时为绿色
当 macd 低于信号时红色
study(title="MACD V5", shorttitle="MACD V5") source = close useCurrentRes = input(true, title="Use Current Chart Resolution?") resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=resolution, defval="60") smd = input(true, title="Show MacD & Signal Line? Also Turn Off Dots Below") sd = input(true, title="Show Dots When MacD Crosses Signal Line?") sh = input(true, title="Show Histogram?") macd_colorChange = input(true,title="Change MacD Line Color-Signal Line Cross?") hist_colorChange = input(true,title="MacD Histogram 4 Colors?") res = useCurrentRes ? period : resCustom fastLength = input(12, minval=1), slowLength=input(26,minval=1) signalLength=input(9,minval=1) fastMA = ema(source, fastLength) slowMA = ema(source, slowLength) macd = fastMA - slowMA signal = sma(macd, signalLength) hist = macd - signal outMacD = security(tickerid, res, macd) outSignal = security(tickerid, res, signal) outHist = security(tickerid, res, hist) histA_IsUp = outHist > outHist[1] and outHist > 0 histA_IsDown = outHist < outHist[1] and outHist > 0 histB_IsDown = outHist < outHist[1] and outHist <= 0 histB_IsUp = outHist > outHist[1] and outHist <= 0 //MacD Color Definitions macd_IsAbove = outMacD >= outSignal macd_IsBelow = outMacD < outSignal plot_color = hist_colorChange ? histA_IsUp ? aqua : histA_IsDown ? blue : histB_IsDown ? red : histB_IsUp ? maroon :yellow :gray macd_color = macd_colorChange ? macd_IsAbove ? lime : red : red signal_color = macd_colorChange ? macd_IsAbove ? yellow : yellow : lime circleYPosition = outSignal plot(smd and outMacD ? outMacD : na, title="MACD", color=macd_color, linewidth=2) plot(smd and outSignal ? outSignal : na, title="Signal Line", color=signal_color, style=line ,linewidth=2) plot(sh and outHist ? outHist : na, title="Histogram", color=plot_color, style=histogram, linewidth=4) plot(sd and cross(outMacD, outSignal) ? circleYPosition : na, title="Cross", style=circles, linewidth=3, color=macd_color) hline(0, '0 Line', linestyle=solid, linewidth=2, color=white) band1 = hline(25, "Upper Band", color=#ff0000) band0 = hline(-25, "Lower Band", color=#00ff0a)
完全不知道怎么做
你有 fill()
功能。
fill_color = outMacD > outSignal ? green : red
p_macd = plot(smd and outMacD ? outMacD : na, title="MACD", color=macd_color, linewidth=2)
p_sig = plot(smd and outSignal ? outSignal : na, title="Signal Line", color=signal_color, style=line ,linewidth=2)
fill(p_macd, p_sig, fill_color, 85)