I have a script that displays the number of days before earnings. I think I have made it too complex and it is not displaying exactly as I would like. The problems are:
1. On stocks that do not have earings it displays loading, I would like to see N/A.
2. If earnings are greater than 15 days it displays > 15 days yet from 1 to 14 it only displays the number of days.
3. The day of earnings it does not appear to be displaying B4 Open or After Close.
Would appreciate some help on this code.
def pg = GetEventOffset(Events.earnings, 0);
def isAfter = HasEarnings(EarningTime.AFTER_MARKET);
def isBefore = HasEarnings(EarningTime.BEFORE_MARKET)[-1];
addlabel(!isnan(pg) and pg<=0,
if pg == -14 then " 14" else
if pg == -13 then " 13" else
if pg == -12 then " 12" else
if pg == -11 then " 11" else
if pg == -10 then " 10" else
if pg == -9 then " 9" else
if pg == -8 then " 8" else
if pg == -7 then " 7" else
if pg == -6 then " 6" else
if pg == -5 then " 5" else
if pg == -4 then " 4" else
if pg == -3 then " 3" else
if pg == -2 then " 2" else
if pg == -1 and isBefore then " 1-B4 Open" else
if pg == -1 then " 1" else
if ((pg == 0 and isafter == 1) ) then "After Close" else "> 15 Days",Color.white);
1. On stocks that do not have earings it displays loading, I would like to see N/A.
2. If earnings are greater than 15 days it displays > 15 days yet from 1 to 14 it only displays the number of days.
3. The day of earnings it does not appear to be displaying B4 Open or After Close.
Would appreciate some help on this code.
def pg = GetEventOffset(Events.earnings, 0);
def isAfter = HasEarnings(EarningTime.AFTER_MARKET);
def isBefore = HasEarnings(EarningTime.BEFORE_MARKET)[-1];
addlabel(!isnan(pg) and pg<=0,
if pg == -14 then " 14" else
if pg == -13 then " 13" else
if pg == -12 then " 12" else
if pg == -11 then " 11" else
if pg == -10 then " 10" else
if pg == -9 then " 9" else
if pg == -8 then " 8" else
if pg == -7 then " 7" else
if pg == -6 then " 6" else
if pg == -5 then " 5" else
if pg == -4 then " 4" else
if pg == -3 then " 3" else
if pg == -2 then " 2" else
if pg == -1 and isBefore then " 1-B4 Open" else
if pg == -1 then " 1" else
if ((pg == 0 and isafter == 1) ) then "After Close" else "> 15 Days",Color.white);