Ok, I think I understand. So in the normal code the trend is defined as any close above (bullish) or below (bearish) the 20 EMA. In the first example here the day opened well under the Moving average in these cases, bulls need to prove that they can break above the average price. So the color here should be red with only the possibility of a green breakout, that breakout is less noisy I believe with consecutive green bars.

The second picture shows again that price opened well below the MA and bulls need to prove a breakout beyond the MA, here it became resistance.

The third picture everything looks good besides how the day opened.

The 4th picture shows the code working perfectly and how the Consecutive breakout cuts out noise. The only error is that the trend momentarily turns green due to a doji.

The 5th picture There is a 2 bar bear breakout that isn't detected so trend should have turned red

Last picture is another example where there is a 2 bar breakout and the trend doesn't change.

Tell me if this makes sense now

date and times are included upper left of picture

please allow me to pop in with my 2 cents,

@Trigun1127
no, you don't seem to understand.

you are mixing in your interpretation of the chart activity with what is actually happening.

programmers need to follow a set of rules. if this happens, do this. if that happens then do this...

if close is above an average for 3 bars, then plot an up arrow.

programmers don't care about these statements. they mean nothing.

..bulls need to prove that...

..that breakout is less noisy...

..bulls need to prove a breakout...

..breakout cuts out noise...

if you want to mention your thoughts , please do it after listing a specific set of rules.