Dynamic Variables: The script defines dynamicHigh, dynamicLow, dynamicOpen, and dynamicClose to track the high, low, open, and close values of candles.
Update Dynamic Values: Dynamic values are updated based on the close price. If dynamicHigh or dynamicLow is na, or if the current close breaches either threshold, the values are set to the current candle's high, low, open, and close.
Determine Bullish and Bearish Conditions: The script checks if dynamicClose is less than dynamicOpen to identify bearish conditions or if dynamicClose is greater than dynamicOpen for bullish conditions.
Bar Color: Bars are colored green when dynamicClose is greater than dynamicOpen, indicating a bullish condition, and red when it is less, indicating a bearish condition.