本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © dgtrd
//@version=4
study("SuperTrend Colored with Ichimoku + Directional Movement Line + VBCB by DGT", shorttitle="ST(ICHIMOKU) + CDMI + VBCB by DGT", overlay=true)
// global variables
v_show_last = input(233, "Plotting Lookback Bars Length")
source = input(title="Source", defval=close)
// Show Ichimoku Colored Super Trend
showST = input(true, title = "Show Ichimoku Colored Super Trend")
conversionPeriods = input(20, minval=1, title="Conversion Line Periods"),
basePeriods = input(60, minval=1, title="Base Line Periods")
laggingSpan2Periods = input(120, minval=1, title="Lagging Span 2 Periods"),
displacement = input(30, minval=1, title="Displacement")
donchian(len) => avg(lowest(len), highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
aboveCloud = source > leadLine1[displacement - 1] and source > leadLine2[displacement - 1]
belowCloud = source < leadLine1[displacement - 1] and source < leadLine2[displacement - 1]
inCloud = (source > leadLine1[displacement - 1] and source < leadLine2[displacement - 1]) or (source < leadLine1[displacement - 1] and source > leadLine2[displacement - 1])
ichiColor = aboveCloud ? (conversionLine >= baseLine ? #006400 : color.green) : belowCloud ? (conversionLine >= baseLine ? #910000 : color.red) : inCloud ? (conversionLine >= baseLine ? color.black : color.gray) : (conversionLine >= baseLine ? color.blue : color.aqua)
stMult = input(3, minval=1, title="The Multiplier Factor of Super Trend")
stLength = input(7, minval=1, title="Length of ATR Periods of Super Trend")
[superTrend, dir] = supertrend(stMult, stLength)
stColor = dir == dir[1] ? dir == -1 ? ichiColor : dir == 1 ? ichiColor : na : na
plot(showST ? superTrend : na, color = stColor, linewidth=2, title="Ichimoku Colored Super Trend", show_last = v_show_last)
// Show DMI Trend & Strength Indicator
showDMI = input(true, title = "Show Colored DMI Trend & Strength Indicator")
adxSmoothing = input(14, title="ADX Smoothing", minval=1)
diLength = input(14, title="DI Length", minval=1)
strongTrend = input(25, title="Strong Trend Theshold")
weekTrend = input(17, title="Week Trend Theshold")
[diplus, diminus, adxValue] = dmi(diLength, adxSmoothing)
dmiBull = diplus >= diminus and adxValue >= strongTrend
dmiBear = diplus < diminus and adxValue >= strongTrend
dmiWeek = adxValue < strongTrend and adxValue > weekTrend
dmiColor = dmiBull ? (adxValue > adxValue[1] ? #006400 : color.green) : dmiBear ? (adxValue > adxValue[1] ? #910000 : color.red ): dmiWeek ? (adxValue > adxValue[1] ? color.black : color.gray) : (adxValue > adxValue[1] ? #FFC40C : color.yellow)
plotshape(showDMI and diplus >= diminus, style=shape.triangleup, location=location.top, color=dmiColor, title="ADX & +DI > -DI", show_last = v_show_last)
plotshape(showDMI and diplus < diminus, style=shape.triangledown, location=location.top, color=dmiColor, title="ADX & +DI < -DI", show_last = v_show_last)
// Volume Based Colored Bars by KIVANÇ ÖZBİLGİÇ
vbcbLength = input(30, title="Volume Based Colored Bars Length", minval=1)
avrg=sma(volume,vbcbLength)
vbcbColor = if close < open
if volume > avrg*1.5
#910000
else if volume >= avrg*0.5 and volume <= avrg*1.5
color.red
else
color.orange
else
if volume > avrg*1.5
#006400
else if volume >= avrg*0.5 and volume <= avrg*1.5
color.green
else
#7FFFD4
barcolor(vbcbColor, title = "Volume Based Colored Bars by [KıvançÖZBİLGİÇ]", show_last = v_show_last)