Generally HH and HL shows up-trend, LL and LH shows down-trend.
If price breaks resistance levels it means the trend is up or if price breaks it means the trend is down, so the script changes bar color blue or black. if there is up-trend then bar color is blue, or if down-trend then bar color is black. also as you can see levels change dynamically.
If you use smaller numbers for left/right bars then it will be more sensitive.
If you find my works useful, please consider a donation
source code of :