#Only use on a daily chart.
AddLabel(yes, "5 Year Seasonal Analysis", color.YELLOW);
#January
def jan = getmonth() == 1;
def janopen = if jan and !jan[1] then open else janopen[1];
def janclose = if jan and !jan[-1] then close else janclose[1];
def jandiff = if jan and !jan[-1] then (janclose-janopen)/janopen else 0;
def janup = totalsum( if jan and !jan[-1] and jandiff > 0 then 1 else 0);
def jandown = totalsum ( if jan and !jan[-1] and jandiff <= 0 then 1 else 0);
def jantotalcount = totalsum(jan and !jan[-1]);
def janavgdiff = totalsum(jandiff)/jantotalcount;
Addlabel(yes, "Jan Avg: " + aspercent( janup/jantotalcount) + " | " + aspercent(janavgdiff), if(janup/jantotalcount) > 0.5 and janavgdiff > 0 then color.green else color.red);
#addchartbubble(jan, close jandiff, color.yellow);
#addchartbubble(mar, close jandiff, color.yellow);
#February
def feb = getmonth() == 2;
def febopen = if feb and !feb[1] then open else febopen[1];
def febclose = if feb and feb[-1] then close else febclose[1];
def febdiff = if feb and !feb[-1] then (febclose-febopen)/febopen else 0;
def febup = totalsum( if feb and !feb[-1] and febdiff > 0 then 1 else 0);
def febdown = totalsum ( if feb and !feb[-1] and febdiff <= 0 then 1 else 0);
def febtotalcount = totalsum(feb and !feb[-1]);
def febavgdiff = totalsum(febdiff)/febtotalcount;
Addlabel(yes, "February Avg: " + aspercent( febup/febtotalcount) + " | " + aspercent(febavgdiff), if(febup/febtotalcount) > 0.5 and febavgdiff > 0 then color.green else color.red);
#addchartbubble(feb, close jandiff, color.yellow);
#MARCH
def mar = getmonth() == 3;
def maropen = if mar and !mar[1] then open else maropen[1];
def marclose = if mar and mar[-1] then close else marclose[1];
def mardiff = if mar and !mar[-1] then (marclose-maropen)/maropen else 0;
def marup = totalsum( if mar and !mar[-1] and mardiff > 0 then 1 else 0);
def mardown = totalsum ( if mar and !mar[-1] and mardiff <= 0 then 1 else 0);
def martotalcount = totalsum(mar and !mar[-1]);
def maravgdiff = totalsum(mardiff)/martotalcount;
Addlabel(yes, "March Avg: " + aspercent( marup/martotalcount) + " | " + aspercent(maravgdiff), if(marup/martotalcount) > 0.5 and maravgdiff > 0 then color.green else color.red);
#addchartbubble(mar, close jandiff, color.yellow);
#APRIL
def apr = getmonth() == 4;
def apropen = if apr and !apr[1] then open else apropen[1];
def aprclose = if apr and !apr[-1] then close else aprclose[1];
def aprdiff = if apr and !apr[-1] then (aprclose-apropen)/apropen else 0;
def aprup = totalsum( if apr and !apr[-1] and aprdiff > 0 then 1 else 0);
def aprdown = totalsum ( if apr and !apr[-1] and aprdiff <= 0 then 1 else 0);
def aprtotalcount = totalsum(apr and !apr[-1]);
def apravgdiff = totalsum(aprdiff)/aprtotalcount;
Addlabel(yes, "April Avg: " + aspercent( aprup/aprtotalcount) + " | " + aspercent(apravgdiff), if(aprup/aprtotalcount) > 0.5 and apravgdiff > 0 then color.green else color.red);
#addchartbubble(apr, close jandiff, color.yellow);
#MAY
def may = getmonth() == 5;
def mayopen = if may and ! may[1] then open else mayopen[1];
def mayclose = if may and ! may[-1] then close else mayclose[1];
def maydiff = if may and ! may[-1] then ( mayclose- mayopen)/ mayopen else 0;
def mayup = totalsum( if may and ! may[-1] and maydiff > 0 then 1 else 0);
def maydown = totalsum ( if may and ! may[-1] and maydiff <= 0 then 1 else 0);
def maytotalcount = totalsum( may and ! may[-1]);
def mayavgdiff = totalsum( maydiff)/ maytotalcount;
Addlabel(yes, "May Avg: " + aspercent( mayup/ maytotalcount) + " | " + aspercent( mayavgdiff), if( mayup/ maytotalcount) > 0.5 and mayavgdiff > 0 then color.green else color.red);
#addchartbubble(may, close jandiff, color.yellow);
#June
def Jun = getmonth() == 6;
def Junopen = if Jun and !Jun[1] then open else Junopen[1];
def Junclose = if Jun and Jun[-1] then close else Junclose[1];
def Jundiff = if Jun and !Jun[-1] then (Junclose-Junopen)/Junopen else 0;
def Junup = totalsum( if Jun and !Jun[-1] and Jundiff > 0 then 1 else 0);
def Jundown = totalsum ( if Jun and !Jun[-1] and Jundiff <= 0 then 1 else 0);
def Juntotalcount = totalsum(Jun and !Jun[-1]);
def Junavgdiff = totalsum(Jundiff)/Juntotalcount;
Addlabel(yes, "June Avg: " + aspercent( Junup/Juntotalcount) + " | " + aspercent(Junavgdiff), if(Junup/Juntotalcount) > 0.5 and Junavgdiff > 0 then color.green else color.red);
#addchartbubble(jun, close jandiff, color.yellow);
#July
def jul = getmonth() == 7;
def julopen = if jul and ! jul[1] then open else julopen[1];
def julclose = if jul and jul[-1] then close else julclose[1];
def juldiff = if jul and ! jul[-1] then ( julclose- julopen)/ julopen else 0;
def julup = totalsum( if jul and ! jul[-1] and juldiff > 0 then 1 else 0);
def juldown = totalsum ( if jul and ! jul[-1] and juldiff <= 0 then 1 else 0);
def jultotalcount = totalsum( jul and ! jul[-1]);
def julavgdiff = totalsum( juldiff)/ jultotalcount;
Addlabel(yes, "July Avg: " + aspercent( julup/ jultotalcount) + " | " + aspercent( julavgdiff), if( julup/ jultotalcount) > 0.5 and julavgdiff > 0 then color.green else color.red);
#addchartbubble(jul, close jandiff, color.yellow);
#August
def aug = getmonth() == 8;
def augopen = if aug and ! aug[1] then open else augopen[1];
def augclose = if aug and ! aug[-1] then close else augclose[1];
def augdiff = if aug and ! aug[-1] then ( augclose- augopen)/ augopen else 0;
def augup = totalsum( if aug and ! aug[-1] and augdiff > 0 then 1 else 0);
def augdown = totalsum ( if aug and ! aug[-1] and augdiff <= 0 then 1 else 0);
def augtotalcount = totalsum( aug and ! aug[-1]);
def augavgdiff = totalsum( augdiff)/ augtotalcount;
Addlabel(yes, "August Avg: " + aspercent( augup/ augtotalcount) + " | " + aspercent( augavgdiff), if( augup/ augtotalcount) > 0.5 and augavgdiff > 0 then color.green else color.red);
#addchartbubble(aug, close jandiff, color.yellow);
#September
def sep = getmonth() == 9;
def sepopen = if sep and !sep[1] then open else sepopen[1];
def sepclose = if sep and !sep[-1] then close else sepclose[1];
def sepdiff = if sep and !sep[-1] then (sepclose-sepopen)/sepopen else 0;
def sepup = totalsum( if sep and !sep[-1] and sepdiff > 0 then 1 else 0);
def sepdown = totalsum ( if sep and !sep[-1] and sepdiff <= 0 then 1 else 0);
def septotalcount = totalsum(sep and !sep[-1]);
def sepavgdiff = totalsum(sepdiff)/septotalcount;
Addlabel(yes, "September Avg: " + aspercent( sepup/septotalcount) + " | " + aspercent(sepavgdiff), if(sepup/septotalcount) > 0.5 and sepavgdiff > 0 then color.green else color.red);
#addchartbubble(sep, close jandiff, color.yellow);
#addchartbubble(mar, close jandiff, color.yellow);
#October
def oct = getmonth() == 10;
def octopen = if oct and !oct[1] then open else octopen[1];
def octclose = if oct and oct[-1] then close else octclose[1];
def octdiff = if oct and !oct[-1] then (octclose-octopen)/octopen else 0;
def octup = totalsum( if oct and !oct[-1] and octdiff > 0 then 1 else 0);
def octdown = totalsum ( if oct and !oct[-1] and octdiff <= 0 then 1 else 0);
def octtotalcount = totalsum(oct and !oct[-1]);
def octavgdiff = totalsum(octdiff)/octtotalcount;
Addlabel(yes, "October Avg: " + aspercent( octup/octtotalcount) + " | " + aspercent(octavgdiff), if(octup/octtotalcount) > 0.5 and octavgdiff > 0 then color.green else color.red);
#addchartbubble(oct, close jandiff, color.yellow);
#November
def nov = getmonth() == 11;
def novopen = if nov and !nov[1] then open else novopen[1];
def novclose = if nov and !nov[-1] then close else novclose[1];
def novdiff = if nov and !nov[-1] then (novclose-novopen)/novopen else 0;
def novup = totalsum( if nov and !nov[-1] and novdiff > 0 then 1 else 0);
def novdown = totalsum ( if nov and !nov[-1] and novdiff <= 0 then 1 else 0);
def novtotalcount = totalsum(nov and !nov[-1]);
def novavgdiff = totalsum(novdiff)/novtotalcount;
Addlabel(yes, "Nov Avg: " + aspercent( novup/novtotalcount) + " | " + aspercent(novavgdiff), if(novup/novtotalcount) > 0.5 and novavgdiff > 0 then color.green else color.red);
#addchartbubble(nov, close jandiff, color.yellow);
#December
def dec = getmonth() == 12;
def decopen = if dec and !dec[1] then open else decopen[1];
def decclose = if dec and dec[-1] then close else decclose[1];
def decdiff = if dec and !dec[-1] then (decclose-decopen)/decopen else 0;
def decup = totalsum( if dec and !dec[-1] and decdiff > 0 then 1 else 0);
def decdown = totalsum ( if dec and !dec[-1] and decdiff <= 0 then 1 else 0);
def dectotalcount = totalsum(dec and !dec[-1]);
def decavgdiff = totalsum(decdiff)/dectotalcount;
Addlabel(yes, "Dec Avg: " + aspercent( decup/dectotalcount) + " | " + aspercent(decavgdiff), if(decup/dectotalcount) > 0.5 and decavgdiff > 0 then color.green else color.red);
#addchartbubble(dec, close jandiff, color.yellow);