Reputation: 121
I want to draw a line using line.new function, that follows the below:
Time Axis : Automatically starts from Market Open and ends at Market Close. For all Markets, International and Local, and Across All Asset Classes. Not restricted to a specified time.
Price Axis: Daily Pivot Point
Your Help is much appreciated. Please
//@version=5
indicator('Pivot', overlay=true, shorttitle='Pivot', precision=1, max_bars_back=4500)
//******************LOGIC**************************
//cenral pivot range
pivot = (high + low + close) / 3 //Central Povit
//******************Line**************************
line.new(x1 = time('D', "open"), y1 = pivot , x2 = time('D', "close"), y2 = pivot , xloc=xloc.bar_time, style=line.style_solid, width = 2, color = color.new(#0000FF, 0)) //
Upvotes: 0
Views: 1380
Reputation: 6865
You could just extend the line to the right.
Also, your pivot calculation has a Pine built-in hlc3
//@version=5
indicator('Pivot', overlay=true, shorttitle='Pivot')
// define line, extend to the right
var line pivotLine = line.new(na, na, na, na, xloc=xloc.bar_time, style=line.style_solid, width=2, color=color.new(#0000FF, 0), extend=extend.right)
pivot = request.security(syminfo.tickerid, 'D', hlc3[1])
// new day?
if ta.change(dayofmonth)
// move line
line.set_xy1(pivotLine, time, pivot)
line.set_xy2(pivotLine, time+1, pivot)
Upvotes: 3