This script finds pivot highs and pivot lows then calculates higher highs & lower lows. And also it calculates support/resistance by using HH-HL-LL-LH points.
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 support level 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 support and resistance levels change dynamically.
If you use smaller numbers for left/right bars then it will be more sensitive.
Hi there, this is amazing ! thank you :) Since I am using linecharts for S/R I modified your code slightly myself but could you perhaps add an option for everyones benefit to use the Close instead of the Highs/Lows for the pivot calculations ? You would only need to modify lines 14 and 15 as follows: