Reputation: 15
I made a pine script for trading view indicator. I want it to plot an uninterrupted line, however I see interrupted line (dashed line) being plotted. I don't know how to resolve this.
I follow the pine script Version 5 user manual on tradingview, but couldn't track the problem.
//@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, show_last=1, title='0', editable=false)
plot(F236, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, show_last=1, title='0.236', editable=false)
plot(F382, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, show_last=1, title='0.382', editable=false)
plot(F500, color=color.new(color.yellow, 0), linewidth=2, style=plot.style_line, trackprice=true, show_last=1, title='Base: 0.5 level', editable=true)
plot(F618, color=color.new(color.yellow, 0), linewidth=2, style=plot.style_line, trackprice=true, show_last=1, title='Base: 0.618 level', editable=true)
plot(F786, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, show_last=1, title='0.786', editable=false)
plot(F1000, color=color.new(Fcolor, 0), linewidth=2, trackprice=true, show_last=1, title='1', editable=false)
//1st increment plot
plot(F0 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0', editable=false)
plot(F236 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0.236', editable=false)
plot(F382 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0.382', editable=false)
plot(F500 + m, color=color.new(color.yellow, 0), linewidth=1, trackprice=true, show_last=1, title='1st increment: 0.5 level', editable=true)
plot(F618 + m, color=color.new(color.yellow, 0), linewidth=1, trackprice=true, show_last=1, title='1st increment: 0.618 level', editable=true)
plot(F786 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0.786', editable=false)
plot(F1000 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, 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, show_last=1, title='0', editable=false)
plot(F236 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0.236', editable=false)
plot(F382 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0.382', editable=false)
plot(F500 + 2 * m, color=color.new(color.yellow, 0), linewidth=1, trackprice=true, show_last=1, title='2nd increment: 0.5 level', editable=true)
plot(F618 + 2 * m, color=color.new(color.yellow, 0), linewidth=1, trackprice=true, show_last=1, title='2nd increment 0.618 level', editable=true)
plot(F786 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='0.786', editable=false)
plot(F1000 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=true, show_last=1, title='1', editable=false)
Upvotes: 1
Views: 769
Reputation: 56
I removed trackprice (this causes the dotted lines to appear) and showlast to show the full line and just one part of it
//@version=5
//Coded by: NawidD.
indicator(title='test fibonacci', overlay=true)
HighPoint = input.float(1.6, title='Set the high level')
LowPoint = input.float(1.5, title='Set the low level')
m = input.float(defval=0.1, title='Set the gap')
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=false, title='0', editable=false)
plot(F236, color=color.new(Fcolor, 0), linewidth=2, trackprice=false, title='0.236', editable=false)
plot(F382, color=color.new(Fcolor, 0), linewidth=2, trackprice=false, title='0.382', editable=false)
plot(F500, color=color.new(color.yellow, 0), linewidth=2, style=plot.style_line, trackprice=false, title='Base: 0.5 level', editable=true)
plot(F618, color=color.new(color.yellow, 0), linewidth=2, style=plot.style_line, trackprice=false, title='Base: 0.618 level', editable=true)
plot(F786, color=color.new(Fcolor, 0), linewidth=2, trackprice=false, title='0.786', editable=false)
plot(F1000, color=color.new(Fcolor, 0), linewidth=2, trackprice=false, title='1', editable=false)
//1st increment plot
plot(F0 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0', editable=false)
plot(F236 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0.236', editable=false)
plot(F382 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0.382', editable=false)
plot(F500 + m, color=color.new(color.yellow, 0), linewidth=1, trackprice=false, title='1st increment: 0.5 level', editable=true)
plot(F618 + m, color=color.new(color.yellow, 0), linewidth=1, trackprice=false, title='1st increment: 0.618 level', editable=true)
plot(F786 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0.786', editable=false)
plot(F1000 + m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, 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), 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), 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), 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), 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), 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), 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), text='%100', offset=5, editable=false)
//2nd increment plot
plot(F0 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0', editable=false)
plot(F236 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0.236', editable=false)
plot(F382 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0.382', editable=false)
plot(F500 + 2 * m, color=color.new(color.yellow, 0), linewidth=1, trackprice=false, title='2nd increment: 0.5 level', editable=true)
plot(F618 + 2 * m, color=color.new(color.yellow, 0), linewidth=1, trackprice=false, title='2nd increment 0.618 level', editable=true)
plot(F786 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='0.786', editable=false)
plot(F1000 + 2 * m, color=color.new(Fcolor, 0), linewidth=1, trackprice=false, title='1', editable=false)
Upvotes: 0