I am trying to add a vertical cloud from the day after earnings through the 7th day after earnings that is colored either green or red depending on either a positive or negative return. I have the following code below, which sort of works. It plots either a green or red cloud over the first bar after earnings which correctly corresponds to the either a positive or negative move, however, as you can see the rest of the cloud plots a yellowish color for both a green and red cloud. Im using a calculation (EGap, shown below) to determine either a positive or negative return (which I know is working correctly from another script). Does anyone know why the cloud is not plotting either green or red the whole way through? Thanks!
EGap:
def EGap = fold y = 0 to 1
while DayAfterBN do
if (bn - DayAfterBN) <= 1 then close[-6] - open
else Double.NaN;
Cloud:
AddCloud(if Highest(HasEarnings(), 7) AND EGap >= 0 then Double.POSITIVE_INFINITY else Double.NaN, if Highest(HasEarnings(), 7) AND EGap >= 0 then Double.NEGATIVE_INFINITY else Double.NaN, Color.GREEN);
AddCloud(if Highest(HasEarnings(), 7) AND EGap <= 0 then Double.POSITIVE_INFINITY else Double.NaN, if Highest(HasEarnings(), 7) AND EGap <= 0 then Double.NEGATIVE_INFINITY else Double.NaN, Color.Red);
EGap:
def EGap = fold y = 0 to 1
while DayAfterBN do
if (bn - DayAfterBN) <= 1 then close[-6] - open
else Double.NaN;
Cloud:
AddCloud(if Highest(HasEarnings(), 7) AND EGap >= 0 then Double.POSITIVE_INFINITY else Double.NaN, if Highest(HasEarnings(), 7) AND EGap >= 0 then Double.NEGATIVE_INFINITY else Double.NaN, Color.GREEN);
AddCloud(if Highest(HasEarnings(), 7) AND EGap <= 0 then Double.POSITIVE_INFINITY else Double.NaN, if Highest(HasEarnings(), 7) AND EGap <= 0 then Double.NEGATIVE_INFINITY else Double.NaN, Color.Red);