0

Open Source code is below & getting error.

indicator("Advanced Donchian Channels", shorttitle = "[ADC]",overlay = true, max_lines_count = 500)

len = input.int(20, title ="Len", minval = 1, maxval = 166, group = "Advanced Donchian Channel")
fut_tog = input.bool(true, title = "Plot Future Lines?")
color1 = input.color(color.rgb(38,208,124), title = "", inline = "1", group = "Colors")
color2 = input.color(color.rgb(0,150,255), title = "", inline = "1", group = "Colors")
color3 = input.color(color.rgb(255,3,62), title = "", inline = "1", group = "Colors")


highst = ta.highest(high,len)
lowst = ta.lowest(low,len)
mean = math.avg(highst,lowst)

highbar = ta.barssince(high == highst)
lowbar = ta.barssince(low == lowst)

dir = highbar>lowbar?2:lowbar>highbar?1:0

var fut_lines = array.new_line(na)
if array.size(fut_lines) > 0
    for i = 0 to array.size(fut_lines) - 1
        line.delete(array.get(fut_lines, i))
array.clear(fut_lines)

if fut_tog
    for i = len to 2
        low1 = ta.lowest(low,i)
        low2 = ta.lowest(low,i-1)
        high1 = ta.highest(high,i)
        high2 = ta.highest(high,i-1)
        array.push(fut_lines,line.new(bar_index + (len-i), high1,(bar_index +(len-i))+ 1,high2, color = color1, style = line.style_dotted))
        array.push(fut_lines,line.new(bar_index + (len-i), math.avg(high1,low1),(bar_index +(len-i))+ 1,math.avg(high2,low2), color = color2, style = line.style_dotted))
        array.push(fut_lines,line.new(bar_index + (len-i), low1,(bar_index +(len-i))+ 1,low2, color = color3, style = line.style_dotted))

//PLOTS
plot(highst, title = "Highest", color = color1, linewidth = 2, editable = false)
plot(mean,title = "Mean", color = color2, linewidth = 1, editable = false)
plot(lowst, title = "Lowest", color = color3, linewidth = 2, editable = false)


low1 = ta.lowest(low,i)
low2 = ta.lowest(low,i-1)
high1 = ta.highest(high,i)
high2 = ta.highest(high,i-1)

Above 4 lines (low1, low2, high1, high2) I am getting error like this, The function ta.lowest should be called on each calculation for consistency. It is recommended to extract the call from this scope.

The function ta.highest should be called on each calculation for consistency. It is recommended to extract the call from this scope.

Pls provide me solution and with new code, as I am very new to Pinescript.

Thanks, Regards RR

rr1050
  • 3
  • 3

1 Answers1

0

This is not an error message. It is a warning message.

It warns you that by using those functions in a local scope, you are breaking the history of those variables.

This could be acceptable depending on your use case.

vitruvius
  • 15,740
  • 3
  • 16
  • 26