我有一个5 EMA指标,我想按以下方法进行转换。
我希望水平线自动对齐,该水平线目前我每天手动移动到当前EMA值(然后使EMA指示器不可见,从而仅显示H线)。
我已经使用了几个现成的代码片段,但是我找不到解决方案。我尝试使用“ 24x7”,“ 00:00”和相应的命令等,但是我听不到。我也不想看到前一天的线条。你知道我的意思?它应该仅在00:00时自动将我的H线移动到相应EMA的值。我已经在Google搜索了很长时间,但是找不到任何可以作为初学者使用的东西。
//5 Horizontal EMA by -=Tre$aCo7n=-
//Modified from 4 Exponential Moving Averages from @vitastrato
study(title="5 Horizontal EMA", shorttitle="5 H. EMA", overlay=true)
len1 = input(10, minval=8, title="Length")
len2 = input(21, minval=8, title="Length")
len3 = input(55, minval=8, title="Length")
len4 = input(100, minval=8, title="Length")
len5 = input(200, minval=8, title="Length")
src = input(close, title="Source")
entryema = ema(src, len1)
fastema = ema(src, len2)
mediumema = ema(src, len3)
slowema = ema(src, len4)
veryslowema = ema(src, len5)
plot(entryema, color=green, linewidth=3, title="Entry EMA")
plot(fastema, color=orange, linewidth=3, title="Fast EMA")
plot(mediumema, color=red, linewidth=3, title="Medium EMA")
plot(slowema, color=white, linewidth=3, title="Slow EMA")
plot(veryslowema, color=purple, linewidth=3, title="Veryslow EMA")```
答案 0 :(得分:0)
这将显示您的需求。
截止时间00:00
以交换时间表示。
//@version=4
//5 Horizontal EMA by -=Tre$aCo7n=-
//Modified from 4 Exponential Moving Averages from @vitastrato
study(title="5 Horizontal EMA", shorttitle="5 H. EMA", overlay=true)
len1 = input(10, minval=8, title="Length")
len2 = input(21, minval=8, title="Length")
len3 = input(55, minval=8, title="Length")
len4 = input(100, minval=8, title="Length")
len5 = input(200, minval=8, title="Length")
src = input(close, title="Source")
var bool show_hlines = input(true, "Show horizontal lines", input.bool)
var bool show_emas = not show_hlines
var color_entryema = color.green
var color_fastema = color.orange
var color_mediumema = color.red
var color_slowema = color.white
var color_veryslowema = color.purple
var line_entryema = line.new(x1=na, y1=na, x2=na, y2=na, xloc=xloc.bar_time, extend=extend.right, color=show_hlines ? color_entryema : na, style=line.style_dashed)
var line_fastema = line.new(x1=na, y1=na, x2=na, y2=na, xloc=xloc.bar_time, extend=extend.right, color=show_hlines ? color_fastema : na, style=line.style_dashed)
var line_mediumema = line.new(x1=na, y1=na, x2=na, y2=na, xloc=xloc.bar_time, extend=extend.right, color=show_hlines ? color_mediumema : na, style=line.style_dashed)
var line_slowema = line.new(x1=na, y1=na, x2=na, y2=na, xloc=xloc.bar_time, extend=extend.right, color=show_hlines ? color_slowema : na, style=line.style_dashed)
var line_veryslowema = line.new(x1=na, y1=na, x2=na, y2=na, xloc=xloc.bar_time, extend=extend.right, color=show_hlines ? color_veryslowema : na, style=line.style_dashed)
f_moveLine(_id, _x, _y) =>
line.set_xy1(_id, _x, _y)
line.set_xy2(_id, _x+1, _y)
entryema = ema(src, len1)
fastema = ema(src, len2)
mediumema = ema(src, len3)
slowema = ema(src, len4)
veryslowema = ema(src, len5)
if (hour==0 and minute==0 and year(time)==year(timenow) and month(time)==month(timenow) and dayofmonth(time)==dayofmonth(timenow))
f_moveLine(line_entryema, time, entryema)
f_moveLine(line_fastema, time, fastema)
f_moveLine(line_mediumema, time, mediumema)
f_moveLine(line_slowema, time, slowema)
f_moveLine(line_veryslowema, time, veryslowema)
plot(entryema, color=show_emas ? color_entryema : na, linewidth=1, title="Entry EMA")
plot(fastema, color=show_emas ? color_fastema : na, linewidth=1, title="Fast EMA")
plot(mediumema, color=show_emas ? color_mediumema : na, linewidth=1, title="Medium EMA")
plot(slowema, color=show_emas ? color_slowema : na, linewidth=1, title="Slow EMA")
plot(veryslowema, color=show_emas ? color_veryslowema : na, linewidth=1, title="Veryslow EMA")