i'm attempting to create a box using line.new
and apply color just to test the linefill.new
function. There seems to be a bug with transparency - even when setting it to 1%, it remains excessively opaque. Is this a bug or could it be an error in my code? I'll include the snippet for reference.
//@version=5
indicator('linefill.new test', overlay=true)
int START_STAMP = timestamp("1 Oct 2023 00:00")
int END_STAMP = timestamp("25 Nov 2023 00:00")
string GROUP_MAIN = 'Main Settings'
int start_main_date = input.time(START_STAMP, title='Start', group=GROUP_MAIN, inline='0')
int end_main_date = input.time(END_STAMP, title='End ', group=GROUP_MAIN, inline='1')
float lowPrice = input.price(50, title='Lowest', group=GROUP_MAIN, inline="2")
float highPrice = input.price(100, title='Highest', group=GROUP_MAIN, inline="2")
color UpCol = input.color(color.new(color.red,50), title='UpCol', inline="1")
color DnCol = input.color(color.new(color.green,50), title='DnCol', inline="1")
float middle_hor = (highPrice - ((highPrice - lowPrice)*0.5))
line _bot = line.new(start_main_date, lowPrice, end_main_date, lowPrice, xloc=xloc.bar_time)
line _top = line.new(start_main_date, highPrice, end_main_date, highPrice, xloc=xloc.bar_time)
line _h3 = line.new(start_main_date, middle_hor, end_main_date, middle_hor, xloc=xloc.bar_time)
linefill.new(_top, _h3, color=UpCol)
linefill.new(_bot, _h3, color=DnCol)
This happens because you have linfills that created on every bar so opacity is stacked
If you change lines to var
(they wil be created only once)
var line _bot = line.new(start_main_date, lowPrice, end_main_date, lowPrice, xloc=xloc.bar_time)
var line _top = line.new(start_main_date, highPrice, end_main_date, highPrice, xloc=xloc.bar_time)
var line _h3 = line.new(start_main_date, middle_hor, end_main_date, middle_hor, xloc=xloc.bar_time)
then it will work