//@version=5
indicator("Line Break Chart")
var linebreak = 3
var current_direction = 1
var last_high = high
var last_low = low
var counter = 0
for i = 1 to 2000
if counter == 0
last_high := high[i]
last_low := low[i]
if current_direction == 1 and close[i] > last_high
current_direction := -1
last_low := close[i]
counter := linebreak - 1
else if current_direction == -1 and close[i] < last_low
current_direction := 1
last_high := close[i]
counter := linebreak - 1
counter := counter - 1
if counter == 0
if current_direction == 1
last_high := high[i]
else
last_low := low[i]
plot(current_direction == 1 ? last_high : last_low, "Line Break Chart", color = current_direction == 1 ? color.green : color.red, style = plot.style_linebr)
i want to plot linebreak chart without using built-in function , i use this code but it plot nothing. is there any other code avalible which plot linebreak chart without using built-in function
You can only query linebreak chart data and associate it with the bars of the current chart using ticker.linebreak()
+ request.security()
, but you cannot create exactly the same chart in terms of the length of the linebreak bars, the scale x(time) cannot be changed.
//@version=5
indicator("ticker.linebreak", overlay = true)
lbTickerid = ticker.linebreak(syminfo.tickerid, 3)
[lbOpen, lbCose] = request.security(lbTickerid, timeframe.period, [open, close], lookahead = barmerge.lookahead_on)
plotcandle(lbOpen, math.max(lbOpen, lbCose), math.min(lbOpen, lbCose), lbCose, color = lbCose < lbOpen ? color.red : color.green)
Note: the security function call in the above example gets the most recent data and is an issue for repainting. To avoid this, remove the lookahead parameter.