Tullius
Tullius

Reputation: 1

Adding Transparency to Hline display/hide function

How do you add color transparency to an optional showing hline in pinescript? I have followed the guide on how to add show/hide optionality into the script by the help of How to display/hide a hline using input from user?, however adding transparency to hline color additionaly has resulted in errors.

This is the optionality line of the code, however succesfully adding the complimentary transparency color part to has proven unsuccessful by my strife:

showHline = input(false)
hline(0, color = showHline ? color.orange : #000000)

Comments: The #000000 at the very end can be arbitrary figures and it does not affect the color

Upvotes: 0

Views: 2278

Answers (1)

beeholder
beeholder

Reputation: 1699

You can add transparency to a color with the color.new() function:

//@version=4
study("My Script")
col1 = color.new(color.red, 80)
l1 = hline(1, color=col1)
plot(na)

Upvotes: 2

Related Questions