In Pine Script, you can achieve this by using conditional statements to check the conditions for each variable and then printing the corresponding string. Here's an example based on your description:
//@version=5
indicator("Print String Based on Variable", overlay=true)
longA = input(true, title="Long A")
longB = input(true, title="Long B")
longC = input(true, title="Long C")
longD = input(true, title="Long D")
// Your conditions to trigger the print
if (longA)
label.new(bar_index, high, text="A", color=color.green, style=label.style_labelup)
if (longB)
label.new(bar_index, high, text="B", color=color.blue, style=label.style_labelup)
if (longC)
label.new(bar_index, high, text="C", color=color.red, style=label.style_labelup)
if (longD)
label.new(bar_index, high, text="D", color=color.purple, style=label.style_labelup)
In this script:
input(true, title="Long A") defines a checkbox input for the
variable longA. You can toggle it on or off in the settings.
The if statements check if each variable is true, and if so, it uses
label.new to display a label on the chart at the current bar's high
with the corresponding text ("A", "B", "C", or "D").
You can customize the appearance of the labels (color, style) according to your preferences. This is a basic example, and you might need to adapt it based on your specific requirements and conditions.