Native Cumulative Delta code irregularity/issue

Copying any native indicator’s code and creating a new indicator using that code as a foundation causes no problems. With the Cumulative Delta indicator, this is not the case. When doing this, after fixing the predef and meta paths, the indicator does work and does show color changes for the delta bars, but fails to change color up/down correctly. For instance, when the price candle goes up past the previous high (strong move), the Cumulative Delta indicator will also and will show green. But if the same candle, before it closes, moves back below the previous high, it turns neutral (or red if below previous low) but still incorrectly shows green. This seems to happen only because you copy the code and make a new indicator with it. You can change nothing about the code, and it will still fail to work properly. This leads to delta bars thay are grey, red, and green all at the same time.

It’s as if it has trouble deleting previously made observations, and just overlaps that old observation with new information leading to delta candles that are a mix of old/new color and value. I can’t figure out what the problem is or how to fix it. Since it happens by simply copying and pasting the Cumulative Delta code without changing anything, it seems impossible.

Please help me if anyone can. This is important to my strategy and trading technique. If anyone needs more information, clarification, or pictures, I’m more than happy to provide it.