Vendrel
Vendrel

Reputation: 987

How to use variables in label.new() text? V5

Instead of displaying static text labels, we may want to make them dynamic and context-dependent.

Upvotes: 0

Views: 1902

Answers (1)

Vendrel
Vendrel

Reputation: 987

//@version=5
indicator("str.tostring() test")

int x = 5
int y = 6
add = x + y
subtract = y - x

if barstate.islast
    Label = label.new(bar_index, high, text = 
     "X + Y = " + str.tostring(add) +
     "\nY - X = " + str.tostring(subtract))

Dynamic LabelText

Upvotes: 2

Related Questions