I am having trouble with correctly assigning background color of a watchlist script. Here it is:
def length = 30;
plot noEarnings = sum(hasearnings(),length)[-length +1] == 0;
addLabel(1, if noEarnings then "Pass" else if !noEarnings then "Fail" else "", color.black);
assignBackGroundColor(if !noEarnings then color.Red else color.Green);
My intent is that if there are no upcoming earnings in the next 30 days, the watchlist cell should say "Pass" and the background color should be green. If there are earnings within 30 days, I want the text to say "Fail" and the background should be colored red.
Here is a snippet of the results:
I can't figure out why the cell with the word "Fail" in it has a background color of green instead of red.
Can anyone help me figure this out.
def length = 30;
plot noEarnings = sum(hasearnings(),length)[-length +1] == 0;
addLabel(1, if noEarnings then "Pass" else if !noEarnings then "Fail" else "", color.black);
assignBackGroundColor(if !noEarnings then color.Red else color.Green);
My intent is that if there are no upcoming earnings in the next 30 days, the watchlist cell should say "Pass" and the background color should be green. If there are earnings within 30 days, I want the text to say "Fail" and the background should be colored red.
Here is a snippet of the results:
I can't figure out why the cell with the word "Fail" in it has a background color of green instead of red.
Can anyone help me figure this out.