//Average rise and fall breakout analysis
//By Vonasi
//20190822
up = up + (high - open)
down = down + (open - low)
count = count + 1
upave = up/count
downave = down/count
if close[1] < open[1] then
rup = rup + (high - open)
rdown = rdown + (open - low)
rcount = rcount + 1
rupave = rup/rcount
rdownave = rdown/rcount
endif
if close[1] > open[1] then
gup = gup + (high - open)
gdown = gdown + (open - low)
gcount = gcount + 1
gupave = gup/gcount
gdownave = gdown/gcount
endif
if barindex > 1 then
if close[1] < open[1] then
upper = open + rupave[1]
lower = open - rdownave[1]
if high > upper then
rupbreak = rupbreak + 1
endif
if low < lower then
rdownbreak = rdownbreak + 1
endif
rbreakcount = rbreakcount + 1
rbreakupave = (rupbreak/rbreakcount) * 100
rbreakdownave = (rdownbreak/rbreakcount) * 100
endif
if close[1] > open[1] then
upper = open + gupave[1]
lower = open - gdownave[1]
if high > upper then
gupbreak = gupbreak + 1
endif
if low < lower then
gdownbreak = gdownbreak + 1
endif
gbreakcount = gbreakcount + 1
gbreakupave = (gupbreak/gbreakcount) * 100
gbreakdownave = (gdownbreak/gbreakcount) * 100
endif
endif
return rbreakupave as "red break up %", gbreakupave as "green break up %", rbreakdownave as "red break down %", gbreakdownave as "green break down %",upave as "Average Rise", downave as "Average Fall", rupave as "Red Average Rise", rdownave as "Red Average Fall", gupave as "Green Average Rise", gdownave as "Green Average Fall"//upper as "upper", lower as "lower"