pine-script

How do I put a separator line between inputs in pinescript?


One picture as example:

enter image description here

I want to make horizontal lines between sections, like in this dialog.

The doc (https://www.tradingview.com/blog/en/organize-script-inputs-in-sections-and-lines-23321/) doesn't have anything about it. I checked ChatGPT as well and didn't get anything out of it.

Is it possible that it's a feature not exposed to pinescript?


Solution

  • You can use a straight line as your group header.

    //@version=6
    indicator("My script", overlay=true)
    
    gr_1 = "________________________________________"
    
    in_1 = input.bool(true, "Input 1", group=gr_1)
    in_2 = input.int(100, "Input 2", group=gr_1)
    
    gr_2 = "_______________________________________"
    
    in_3 = input.bool(true, "Input 3", group=gr_2)
    in_4 = input.int(100, "Input 4", group=gr_2)
    
    gr_3 = "______________________________________"
    
    in_6 = input.bool(true, "Input 5", group=gr_3)
    in_7 = input.int(100, "Input 6", group=gr_3)
    
    gr_4 = "_______________________________________"
    
    in_9 = input.bool(true, "Input 7", group=gr_4)
    in_10 = input.int(100, "Input 8", group=gr_4)
    

    enter image description here

    Please note that, the groups are organized with a string match. So, even though if you have different variable names for the groups, if the strings of those variables are identical, the inputs belonging those groups will be grouped together. Therefore, you need to make sure that the dashed line count is different in each of those headers.