I like this idea, i have a code that's something like that, maybe we could use this to build it out.
declare hide_on_intraday;
# inputs
input PEOne = 10;
input PETwo = 12;
input PEThree = 15;
input PEFour = 16;
input PEFive = 18;
# universals
def c = close;
def bn = BarNumber();
def Earnings = GetActualEarnings();
# subscript for prior value of a BarNumber() defined variable
Script prior {
input of = close;
def priorOf = if of != of[1] then of[1] else priorOf[1];
plot
prior = priorOf;
}
# identifies the which bars are the previous 1,2,3 etc earnings bars
def earningsBar = if !IsNaN(Earnings)
then bn
else earningsBar[1];
def priorEarningsBar1 = prior(earningsBar);
def priorEarningsBar2 = prior(priorEarningsBar1);
def priorEarningsBar3 = prior(priorEarningsBar2);
def priorEarningsBar4 = prior(priorEarningsBar3);
def priorEarningsBar5 = prior(priorEarningsBar4);
def priorEarningsBar6 = prior(priorEarningsBar5);
def priorEarningsBar7 = prior(priorEarningsBar6);
def priorEarningsBar8 = prior(priorEarningsBar7);
def hEB = HighestAll(earningsBar);
def hpEB1 = HighestAll(priorEarningsBar1);
def hpEB2 = HighestAll(priorEarningsBar2);
def hpEB3 = HighestAll(priorEarningsBar3);
def hpEB4 = HighestAll(priorEarningsBar4);
def hpEB5 = HighestAll(priorEarningsBar5);
def hpEB6 = HighestAll(priorEarningsBar6);
def hpEB7 = HighestAll(priorEarningsBar7);
def hpEB8 = HighestAll(priorEarningsBar8);
# defining which 4 earnings are in the running annual total for each quarter
def earnings1;
def earnings2;
def earnings3;
def earnings4;
if bn == hEB {
earnings1 = earnings;
earnings2 = GetValue(earnings, bn - priorEarningsBar1);
earnings3 = GetValue(earnings, bn - priorEarningsBar2);
earnings4 = GetValue(earnings, bn - priorEarningsBar3);
}else{
earnings1 = earnings1[1];
earnings2 = earnings2[1];
earnings3 = earnings3[1];
earnings4 = earnings4[1];
}
def earnings5 = if(bn == hpEB1, earnings, earnings5[1]);
def earnings6 = if(bn == hpEB1, HighestAll(earnings3), earnings6[1]);
def earnings7 = if(bn == hpEB1, HighestAll(earnings4), earnings7[1]);
def earnings8 = if(bn == hpEB1, GetValue(Earnings, hpEB1 - hpEB4),
earnings8[1]);
def earnings9 = if(bn == hpEB2, earnings, earnings9[1]);
def earnings10 = if(bn == hpEB2, HighestAll(earnings7),earnings10[1]);
def earnings11 = if(bn == hpEB2, HighestAll(earnings8),earnings11[1]);
def earnings12 = if(bn == hpEB2, GetValue(earnings, hpEB2 - hpEB5),
earnings12[1]);
def earnings13 = if(bn == hpEB3, earnings, earnings13[1]);
def earnings14 = if(bn == hpEB3,HighestAll(earnings11),earnings14[1]);
def earnings15 = if(bn == hpEB3,HighestAll(earnings12),earnings15[1]);
def earnings16 = if(bn == hpEB3,GetValue(earnings, hpEB3 - hpEB6),
earnings16[1]);
def earnings17 = if(bn == hpEB4, earnings, earnings17[1]);
def earnings18 = if(bn == hpEB4,HighestAll(earnings15),earnings18[1]);
def earnings19 = if(bn == hpEB4,HighestAll(earnings16),earnings19[1]);;
def earnings20 = if(bn == hpEB4,GetValue(earnings, hpEB4 - hpEB7),
earnings20[1]);
def earnings21 = if(bn == hpEB5, earnings, earnings21[1]);
def earnings22 = if(bn == hpEB5, HighestAll(earnings19), earnings22[1]);
def earnings23 = if(bn == hpEB5, HighestAll(earnings20), earnings23[1]);;
def earnings24 = if(bn == hpEB5, GetValue(earnings, hpEB5 - hpEB8),
earnings24[1]);
def aE =
if bn == hpEB5
then earnings21 + earnings22 + earnings23 + earnings24
else if bn == hpEB4
then earnings17 + earnings18 + earnings19 + earnings20
else if bn == hpEB3
then earnings13 + earnings14 + earnings15 + earnings16
else if bn == hpEB2
then earnings9 + earnings10 + earnings11 + earnings12
else
if bn == hpEB1
then earnings5 + earnings6 + earnings7 + earnings8
else if bn == hEB
then earnings1 + earnings2 + earnings3 + earnings4
else aE[1];
plot
"P/E 1" = AE * PEOne;
"P/E 1". SetDefaultColor(CreateColor(100,225,100));
"P/E 1". SetPaintingStrategy(PaintingStrategy.DASHES);
plot
"P/E 2" = AE * PETwo;
"P/E 2". SetDefaultColor(CreateColor(75,175,225));
"P/E 2". SetPaintingStrategy(PaintingStrategy.DASHES);
plot
"P/E 3" = AE * PEThree;
"P/E 3". SetDefaultColor(CreateColor(250,175,50));
"P/E 3". SetPaintingStrategy(PaintingStrategy.DASHES);
plot
"P/E 4" = AE * PEFour;
"P/E 4". SetDefaultColor(CreateColor(200,100,200));
"P/E 4". SetPaintingStrategy(PaintingStrategy.DASHES);
plot
"P/E 5" = AE * PEFive;
"P/E 5". SetDefaultColor(CreateColor(225,100,100));
"P/E 5". SetPaintingStrategy(PaintingStrategy.DASHES);
def locate = !IsNaN(c[3]) && IsNaN(c[2]);
AddChartBubble(locate, "P/E 1", "P/E: "+PEOne+ "\n$"+"P/E 1",
CreateColor(100,225,100));
AddChartBubble(locate, "P/E 2", "P/E: "+PETwo+ "\n$"+"P/E 2",
CreateColor(75,175,225));
AddChartBubble(locate, "P/E 3", "P/E: "+PEThree+ "\n$"+"P/E 3",
CreateColor(250,175,50));
AddChartBubble(locate, "P/E 4", "P/E: "+PEFour+ "\n$"+"P/E 4",
CreateColor(200,100,200));
AddChartBubble(locate, "P/E 5", "P/E: "+PEFive+ "\n$"+"P/E 5",
CreateColor(225,100,100));
# f/ Price to Earnings Lines