//@version=6 indicator("Dabo's 3 Smoothed Heikin Ashi", overlay=false, scale=scale.right) group_display = "① 表示設定" displayCount = input.int(3, "表示する平均足の本数", options=[1, 2, 3], group=group_display) group_smooth = "② Smoothed Heikin Ashi" mult1 = input.int(3, "平均足① 倍率", minval=1, maxval=1000, group=group_smooth) mult2 = input.int(10, "平均足② 倍率", minval=1, maxval=1000, group=group_smooth) mult3 = input.int(30, "平均足③ 倍率", minval=1, maxval=1000, group=group_smooth) f_smoothed_ha(_length) => float smoothOpen = ta.ema(open, _length) float smoothHigh = ta.ema(high, _length) float smoothLow = ta.ema(low, _length) float smoothClose = ta.ema(close, _length) float haClose = (smoothOpen + smoothHigh + smoothLow + smoothClose) / 4.0 float haOpen = na haOpen := na(haOpen[1]) ? (smoothOpen + smoothClose) / 2.0 : (haOpen[1] + haClose[1]) / 2.0 float haHigh = math.max(smoothHigh, math.max(haOpen, haClose)) float haLow = math.min(smoothLow, math.min(haOpen, haClose)) float finalOpen = ta.ema(haOpen, _length) float finalHigh = ta.ema(haHigh, _length) float finalLow = ta.ema(haLow, _length) float finalClose = ta.ema(haClose, _length) [finalOpen, finalHigh, finalLow, finalClose] [haOpen1, haHigh1, haLow1, haClose1] = f_smoothed_ha(mult1) [haOpen2, haHigh2, haLow2, haClose2] = f_smoothed_ha(mult2) [haOpen3, haHigh3, haLow3, haClose3] = f_smoothed_ha(mult3) group_color = "③ 平均足の色" upColor1 = input.color(color.rgb(76, 175, 80), "平均足① 上昇色", group=group_color) downColor1 = input.color(color.rgb(239, 60, 70), "平均足① 下降色", group=group_color) upColor2 = input.color(color.rgb(45, 95, 230), "平均足② 上昇色", group=group_color) downColor2 = input.color(color.rgb(255, 145, 0), "平均足② 下降色", group=group_color) upColor3 = input.color(color.rgb(25, 175, 195), "平均足③ 上昇色", group=group_color) downColor3 = input.color(color.rgb(195, 55, 225), "平均足③ 下降色", group=group_color) group_wick = "④ ヒゲ設定" showWick1 = input.bool(true, "平均足① ヒゲを表示", group=group_wick) showWick2 = input.bool(true, "平均足② ヒゲを表示", group=group_wick) showWick3 = input.bool(true, "平均足③ ヒゲを表示", group=group_wick) isUp1 = haClose1 >= haOpen1 isDown1 = haClose1 < haOpen1 isUp2 = haClose2 >= haOpen2 isDown2 = haClose2 < haOpen2 isUp3 = haClose3 >= haOpen3 isDown3 = haClose3 < haOpen3 haColor1 = isUp1 ? upColor1 : downColor1 haColor2 = isUp2 ? upColor2 : downColor2 haColor3 = isUp3 ? upColor3 : downColor3 wickColor1 = showWick1 ? haColor1 : color.new(haColor1, 100) wickColor2 = showWick2 ? haColor2 : color.new(haColor2, 100) wickColor3 = showWick3 ? haColor3 : color.new(haColor3, 100) plotcandle(displayCount >= 1 ? haOpen1 : na, displayCount >= 1 ? haHigh1 : na, displayCount >= 1 ? haLow1 : na, displayCount >= 1 ? haClose1 : na, title="Smoothed Heikin Ashi ①", color=haColor1, wickcolor=displayCount >= 1 ? wickColor1 : na, bordercolor=displayCount >= 1 ? haColor1 : na) plotcandle(displayCount >= 2 ? haOpen2 : na, displayCount >= 2 ? haHigh2 : na, displayCount >= 2 ? haLow2 : na, displayCount >= 2 ? haClose2 : na, title="Smoothed Heikin Ashi ②", color=haColor2, wickcolor=displayCount >= 2 ? wickColor2 : na, bordercolor=displayCount >= 2 ? haColor2 : na) plotcandle(displayCount >= 3 ? haOpen3 : na, displayCount >= 3 ? haHigh3 : na, displayCount >= 3 ? haLow3 : na, displayCount >= 3 ? haClose3 : na, title="Smoothed Heikin Ashi ③", color=haColor3, wickcolor=displayCount >= 3 ? wickColor3 : na, bordercolor=displayCount >= 3 ? haColor3 : na) allUp1 = isUp1 allDown1 = isDown1 allUp2 = isUp1 and isUp2 allDown2 = isDown1 and isDown2 allUp3 = isUp1 and isUp2 and isUp3 allDown3 = isDown1 and isDown2 and isDown3 allUp = displayCount == 1 ? allUp1 : displayCount == 2 ? allUp2 : allUp3 allDown = displayCount == 1 ? allDown1 : displayCount == 2 ? allDown2 : allDown3 mixedDirection = not allUp and not allDown firstAllUp = allUp and not allUp[1] firstAllDown = allDown and not allDown[1] group_arrow = "⑥ 揃った時の矢印" showArrowUp = input.bool(true, "上昇矢印を表示", group=group_arrow) showArrowDown = input.bool(true, "下降矢印を表示", group=group_arrow) arrowUpColor = input.color(color.rgb(76, 175, 80), "上昇矢印の色", group=group_arrow) arrowDownColor = input.color(color.rgb(239, 60, 70), "下降矢印の色", group=group_arrow) arrowUpShape = input.string("三角", "上昇矢印の形", options=["三角", "矢印", "丸", "ひし形", "ラベル"], group=group_arrow) arrowDownShape = input.string("三角", "下降矢印の形", options=["三角", "矢印", "丸", "ひし形", "ラベル"], group=group_arrow) arrowSize = input.string("小", "矢印サイズ", options=["極小", "小", "中", "大", "特大"], group=group_arrow) plotshape(showArrowUp and firstAllUp and arrowUpShape == "三角" and arrowSize == "極小", title="上昇三角極小", style=shape.triangleup, location=location.belowbar, color=arrowUpColor, size=size.tiny) plotshape(showArrowUp and firstAllUp and arrowUpShape == "三角" and arrowSize == "小", title="上昇三角小", style=shape.triangleup, location=location.belowbar, color=arrowUpColor, size=size.small) plotshape(showArrowUp and firstAllUp and arrowUpShape == "三角" and arrowSize == "中", title="上昇三角中", style=shape.triangleup, location=location.belowbar, color=arrowUpColor, size=size.normal) plotshape(showArrowUp and firstAllUp and arrowUpShape == "三角" and arrowSize == "大", title="上昇三角大", style=shape.triangleup, location=location.belowbar, color=arrowUpColor, size=size.large) plotshape(showArrowUp and firstAllUp and arrowUpShape == "三角" and arrowSize == "特大", title="上昇三角特大", style=shape.triangleup, location=location.belowbar, color=arrowUpColor, size=size.huge) plotshape(showArrowUp and firstAllUp and arrowUpShape == "矢印", title="上昇矢印", style=shape.arrowup, location=location.belowbar, color=arrowUpColor, size=size.small) plotshape(showArrowUp and firstAllUp and arrowUpShape == "丸", title="上昇丸", style=shape.circle, location=location.belowbar, color=arrowUpColor, size=size.small) plotshape(showArrowUp and firstAllUp and arrowUpShape == "ひし形", title="上昇ひし形", style=shape.diamond, location=location.belowbar, color=arrowUpColor, size=size.small) plotshape(showArrowUp and firstAllUp and arrowUpShape == "ラベル", title="上昇ラベル", style=shape.labelup, location=location.belowbar, color=arrowUpColor, size=size.small) plotshape(showArrowDown and firstAllDown and arrowDownShape == "三角" and arrowSize == "極小", title="下降三角極小", style=shape.triangledown, location=location.abovebar, color=arrowDownColor, size=size.tiny) plotshape(showArrowDown and firstAllDown and arrowDownShape == "三角" and arrowSize == "小", title="下降三角小", style=shape.triangledown, location=location.abovebar, color=arrowDownColor, size=size.small) plotshape(showArrowDown and firstAllDown and arrowDownShape == "三角" and arrowSize == "中", title="下降三角中", style=shape.triangledown, location=location.abovebar, color=arrowDownColor, size=size.normal) plotshape(showArrowDown and firstAllDown and arrowDownShape == "三角" and arrowSize == "大", title="下降三角大", style=shape.triangledown, location=location.abovebar, color=arrowDownColor, size=size.large) plotshape(showArrowDown and firstAllDown and arrowDownShape == "三角" and arrowSize == "特大", title="下降三角特大", style=shape.triangledown, location=location.abovebar, color=arrowDownColor, size=size.huge) plotshape(showArrowDown and firstAllDown and arrowDownShape == "矢印", title="下降矢印", style=shape.arrowdown, location=location.abovebar, color=arrowDownColor, size=size.small) plotshape(showArrowDown and firstAllDown and arrowDownShape == "丸", title="下降丸", style=shape.circle, location=location.abovebar, color=arrowDownColor, size=size.small) plotshape(showArrowDown and firstAllDown and arrowDownShape == "ひし形", title="下降ひし形", style=shape.diamond, location=location.abovebar, color=arrowDownColor, size=size.small) plotshape(showArrowDown and firstAllDown and arrowDownShape == "ラベル", title="下降ラベル", style=shape.labeldown, location=location.abovebar, color=arrowDownColor, size=size.small) group_bg = "⑦ 背景設定" showBackground = input.bool(true, "背景色を表示", group=group_bg) backgroundUpColor = input.color(color.rgb(76, 175, 80), "3本上昇揃い 背景色", group=group_bg) backgroundDownColor = input.color(color.rgb(239, 60, 70), "3本下降揃い 背景色", group=group_bg) showMixedBackground = input.bool(true, "バラバラ時の背景を表示", group=group_bg) backgroundMixedColor = input.color(color.white, "バラバラ時の背景色", group=group_bg) backgroundTransparency = input.int(60, "背景の透明度", minval=0, maxval=100, group=group_bg) backgroundColor = allUp ? color.new(backgroundUpColor, backgroundTransparency) : allDown ? color.new(backgroundDownColor, backgroundTransparency) : mixedDirection and showMixedBackground ? color.new(backgroundMixedColor, backgroundTransparency) : na bgcolor(showBackground ? backgroundColor : na, title="方向別背景")