I've been working on a bar painter by borrowing some code from others, but just can't get the thing to work correctly.
The idea is pretty simple:
Look for 2 conditions to identify a trend change.
For down trend
A) The current bar closes below the low of the previous bar
B) The next consecutive bar trades below the current bar
If both A & B are true, paint the bars red and keep painting red bars until an uptrend appears.
Opposite true for uptrend.
In the image below, I've circled some of the bars that meet condition A. Not all those I've circled meet condition B as well. But the overall idea is to find the first set of 3 bars the meet both conditions and start painting the bars. Then keep painting the bars until the opposite trend appears, which will cause the new paint color to appear. In the image I've used lines to indicate which bars would be painted red or green.
I'm wondering if someone can help me with this code?