Pine Script V5指标绘制连续直线异常显示为虚线求助
解决Pine Script V5斐波那契指标线条中断问题
你的指标线条呈现中断虚线的核心原因是所有plot()函数都添加了show_last=1参数,这个参数会强制只渲染最后1个数据点,导致原本应该连续的线条变成孤立短段。同时代码里还有几处语法错误需要修正,以下是修复后的完整代码:
//@version=5 //Coded by: NawidD. indicator(title='test fibonacci', overlay=true) HighPoint = input(1.6, title='Set the high level') LowPoint = input(1.5, title='Set the low level') m = input.float(title='Set the gap', defval=0.1) Fhigh = HighPoint Flow = LowPoint //First data F0 = Flow F236 = (Fhigh - Flow) * 0.236 + Flow F382 = (Fhigh - Flow) * 0.382 + Flow F500 = (Fhigh - Flow) * 0.500 + Flow F618 = (Fhigh - Flow) * 0.618 + Flow F786 = (Fhigh - Flow) * 0.786 + Flow F1000 = (Fhigh - Flow) * 1.000 + Flow Fcolor = #00bfff plot(F0, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, title='0', editable=false) plot(F236, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, title='0.236', editable=false) plot(F382, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, title='0.382', editable=false) plot(F500, color=color.new(color.yellow, 0), linewidth=2, style=plot.style_line, trackprice=true, title='Base: 0.5 level', editable=true) plot(F618, color=color.new(color.yellow, 0), linewidth=2, style=plot.style_line, trackprice=true, title='Base: 0.618 level', editable=true) plot(F786, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, title='0.786', editable=false) plot(F1000, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, title='1', editable=false) //1st increment plot plot(F0 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, title='0', editable=false) plot(F236 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, title='0.236', editable=false) plot(F382 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, title='0.382', editable=false) plot(F500 + m, color=color.new(color.yellow, 0), linewidth=1, trackprice=true, title='1st increment: 0.5 level', editable=true) plot(F618 + m, color=color.new(color.yellow, 0), linewidth=1, trackprice=true, title='1st increment: 0.618 level', editable=true) plot(F786 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, title='0.786', editable=false) plot(F1000 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, title='1', editable=false) //1st increment plot labels //plotshape(F0 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), show_last=1, text='%0', offset=5, editable=false) //plotshape(F236 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), show_last=1, text='%23.6', offset=5, editable=false) //plotshape(F382 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), show_last=1, text='%38.2', offset=5, editable=false) //plotshape(F500 + m, style=shape.labeldown, location=location.absolute, color=color.new(color.yellow, 30), textcolor=color.new(color.black, 30), show_last=1, text='%50', offset=5, editable=false) //plotshape(F618 + m, style=shape.labeldown, location=location.absolute, color=color.new(color.yellow, 30), textcolor=color.new(color.black, 30), show_last=1, text='%61.8', offset=5, editable=false) //plotshape(F786 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), show_last=1, text='%78.6', offset=5, editable=false) //plotshape(F1000 + m, style=shape.labeldown, location=location.absolute, color=color.new(Fcolor, 30), textcolor=color.new(color.black, 30), show_last=1, text='%100', offset=5, editable=false) //2nd increment plot plot(F0 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, title='0', editable=false) plot(F236 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, title='0.236', editable=false) plot(F382 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, title='0.382', editable=false) plot(F500 + 2 * m, color=color.new(color.yellow, 0), linewidth=1, trackprice=true, title='2nd increment: 0.5 level', editable=true) plot(F618 + 2 * m, color=color.new(color.yellow, 0), linewidth=1, trackprice=true, title='2nd increment 0.618 level', editable=true) plot(F786 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, title='0.786', editable=false) plot(F1000 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, title='1', editable=false)
关键修改点:
- 移除所有
plot()函数中的show_last=1参数,让线条从图表起始位置连续绘制到当前K线 - 修正语法错误:将
indicator标题中的中文单引号改为英文单引号,补全HighPoint输入参数中缺失的闭合引号 - 保留
trackprice=true参数,确保线条随价格轴缩放正常显示
内容的提问来源于stack exchange,提问作者Nawid Daliry
相关产品推荐
相关产品推荐

