I am looking for a script to assign color based on trend control. I've attached an image with colored arrows for example.
1. Uptrend = assume up-bars are making new highs, the next bar is a down-bar, but doesn't close lower than the previous green bar open. I need that bar to stay "green". Same for subsequent down-bars that don't close lower than the last up-bar. A down-bar that closes lower than the last up-bar open, should continue to color as down.
2. Downtrend = just the opposite. Down-bars painting red, then an up-bar, but doesn't close higher than the open of the down-bar; it needs to paint as as a down-bar. Up-bar only paints green, if it closes higher than close of the last down-bar.
1. Uptrend = assume up-bars are making new highs, the next bar is a down-bar, but doesn't close lower than the previous green bar open. I need that bar to stay "green". Same for subsequent down-bars that don't close lower than the last up-bar. A down-bar that closes lower than the last up-bar open, should continue to color as down.
2. Downtrend = just the opposite. Down-bars painting red, then an up-bar, but doesn't close higher than the open of the down-bar; it needs to paint as as a down-bar. Up-bar only paints green, if it closes higher than close of the last down-bar.
Last edited: