Rinku
Rinku

Reputation: 133

Am getting String too long error using a loop

I am using a counter to add the previous string to a new string. Am quite sure that the resultant string value is less than 4096. But keep getting the String too long error! What's the mistake I am making and what's the solution?

Thanks

indicator("My script")
test = array.new_float(0,0)
for i = 1 to 12
    array.push(test,time)


array.sort(test,order.descending)

var string fdate1label =""
for i = 0 to array.size(test)-1
    fdate1label:=fdate1label+"\n"+str.format("{0,date, dd-MM-y}",(array.get(test,i)))

if barstate.islast
    checklabel=label.new(bar_index+5, close, "dates " + fdate1label, style = label.style_label_lower_left, size = size.normal)

Upvotes: 0

Views: 780

Answers (1)

vitruvius
vitruvius

Reputation: 21121

You don't need the var keyword.

Your script is executed on every bar. When you have a var, its value is kept for the next execution.

Upvotes: 3

Related Questions