I should mention that a green bar on the chart is defined as the close being greater than the open. It's all determined within the same bar. Your code does not behave this way but instead compares the close of the current bar to the close of the previous bar. It is still possible for a bar to close higher than the previous close and be colored red on the chart.
So for my solution I have adjusted the names of the variables to make it more clear as to exactly what is being measured and displayed.
def newDay = GetDay() <> GetDay()[1];
def higherClose = close > close[1];
rec countHigherCloseBars = if newDay then higherClose else if higherClose then countHigherCloseBars[1] + 1 else countHigherCloseBars[1];
rec countAllBars = if newDay then 1 else countAllBars[1] + 1;
plot count = countHigherCloseBars;
count.AssignValueColor(if count >= 0.5 * countAllBars then Color.GREEN else Color.RED);