Style inputs for Label/Line (TradingView / PineScript)

Style input for Label & Line

kodify (here and here) show the examples that are the only possible ways to create inputs for label or line parameters.

for Line:

myLineStyle = input( options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], defval="solid (─)")
lineStyleChooser(s)=>(s == "dotted (┈)") ? line.style_dotted : (s == "dashed (╌)") ? line.style_dashed : (s == "arrow left (←)") ? line.style_arrow_left : (s == "arrow right (→)") ? line.style_arrow_right : (s == "arrows both (↔)") ? line.style_arrow_both : line.style_solid

if (barstate.islast)
    line.new(bar_index, low, bar_index-5, low, style=lineStyleChooser(myLineStyle) )
    ...

for Label:

myLabelStyle = input( options=["Triangle up (▲)", "Triangle down (▼)", "Arrow up (↑)", "Arrow down (↓)", "Label up (⬆)", "Label down (⬇)", "Plus (+)", "Cross (⨯)", "Circle (●)", "Diamond (◆)", "Flag (⚑)", "Square (■)", "None"], defval="Label down (⬇)" )
labelStyleChooser(s)=> (s == "Triangle up (▲)") ? label.style_triangleup : (s == "Triangle down (▼)") ? label.style_triangledown : (s == "Arrow up (↑)") ? label.style_arrowup : (s == "Arrow down (↓)") ? label.style_arrowdown : (s == "Label up (⬆)") ? label.style_labelup : (s == "Label down (⬇)") ? label.style_labeldown : (s == "Plus (+)") ? label.style_cross: (s == "Cross (⨯)") ? label.style_xcross : (s == "Circle (●)") ? label.style_circle : (s == "Diamond (◆)") ? label.style_diamond : (s == "Flag (⚑)") ? label.style_flag : (s == "Square (■)") ? label.style_square : (s == "None") ? label.style_none : label.style_labeldown

if (barstate.islast)
    label.new(bar_index, high, style=labelStyleChooser(myLabelStyle) )
    ...
Leave a Reply

Your email address will not be published. Required fields are marked *